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_r342396155
 
 

 ##########
 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:
   ```
   postgres=# select interval '1 year' = interval '360 days';
    ?column?
   ----------
    t
   (1 row)
   
   postgres=# select interval '1 mon' = interval '30 days';
    ?column?
   ----------
    t
   (1 row)
   
   postgres=# select interval '1 mon' = interval '31 days';
    ?column?
   ----------
    f
   (1 row)
   
   postgres=# select interval '1 year' = interval '365 days';
    ?column?
   ----------
    f
   (1 row)
   ```
   If we are more likely to keep compatibility with pg, so a year is 360 days 
not 365 days, a month  is 30 days

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to