spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] yaooqinn commented on a change in pull request #26337: [SPARK-29679][SQL] Make interval type comparable and orderable
Date Tue, 05 Nov 2019 09:51:08 GMT
yaooqinn commented on a change in pull request #26337: [SPARK-29679][SQL] Make interval type
comparable and orderable
URL: https://github.com/apache/spark/pull/26337#discussion_r342467923
 
 

 ##########
 File path: common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
 ##########
 @@ -78,6 +81,27 @@ public int hashCode() {
     return Objects.hash(months, days, microseconds);
   }
 
+  @Override
+  public int compare(CalendarInterval that) {
+    long thisAdjustDays = this.microseconds / MICROS_PER_DAY + this.days + this.months *
30;
 
 Review comment:
   In Postgres, interval comparison will treat year as 12 months if comparing with month,
360 days if comparing day and 8640 hours if comparing with hours. This is different from date
add/subtract, where '1 year' is based on what kind of year it is added to.
   
   This is same as interval division
   
   ```sql
   postgres=# select interval '1 year' / 360;
    ?column?
   -----------
    1 0:00:00
   (1 row)
   
   postgres=# select interval '1 year' / 365;
      ?column?
   ---------------
    23:40:16.4064
   (1 row)
   ```

----------------------------------------------------------------
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