spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] MaxGekk commented on a change in pull request #26132: [SPARK-29387][SQL] Support `*` and `/` operators for intervals
Date Tue, 05 Nov 2019 08:06:33 GMT
MaxGekk commented on a change in pull request #26132: [SPARK-29387][SQL] Support `*` and `/`
operators for intervals
URL: https://github.com/apache/spark/pull/26132#discussion_r342423315
 
 

 ##########
 File path: common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
 ##########
 @@ -59,6 +59,27 @@ public CalendarInterval subtract(CalendarInterval that) {
     return new CalendarInterval(months, days, microseconds);
   }
 
+  private static CalendarInterval fromDoubles(
+      double monthsWithFraction,
+      double daysWithFraction,
+      double microsWithFraction) {
+    int truncatedMonths = Math.toIntExact((long)(monthsWithFraction));
+    // Using 30 days per month as PostgreSQL does.
+    double days = daysWithFraction + 30 * (monthsWithFraction - truncatedMonths);
+    int truncatedDays = Math.toIntExact((long)days);
+    double micros = microsWithFraction + MICROS_PER_DAY * (days - truncatedDays);
+    long truncatedMicros = Math.round(micros);
+    return new CalendarInterval(truncatedMonths, truncatedDays, truncatedMicros);
+  }
+
+  public CalendarInterval multiply(double num) {
 
 Review comment:
   > Double is not big enough to support the average aggregate ...
   
   @yaooqinn Could you explain what do you mean? I could image that `double` is not precise
enough but not big though ...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message