You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/10/16 08:52:02 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #26134: [SPARK-29486][SQL] CalendarInterval should have 3 fields: months, days and microseconds

MaxGekk commented on a change in pull request #26134: [SPARK-29486][SQL] CalendarInterval should have 3 fields: months, days and microseconds
URL: https://github.com/apache/spark/pull/26134#discussion_r335330334
 
 

 ##########
 File path: common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
 ##########
 @@ -111,14 +111,13 @@ public static CalendarInterval fromCaseInsensitiveString(String s) {
     }
 
     long months = toLong(m.group(1)) * 12 + toLong(m.group(2));
-    long microseconds = toLong(m.group(3)) * MICROS_PER_WEEK;
-    microseconds += toLong(m.group(4)) * MICROS_PER_DAY;
-    microseconds += toLong(m.group(5)) * MICROS_PER_HOUR;
+    long days = toLong(m.group(3)) * 7 + toLong(m.group(4));
+    long microseconds = toLong(m.group(5)) * MICROS_PER_HOUR;
     microseconds += toLong(m.group(6)) * MICROS_PER_MINUTE;
     microseconds += toLong(m.group(7)) * MICROS_PER_SECOND;
     microseconds += toLong(m.group(8)) * MICROS_PER_MILLI;
     microseconds += toLong(m.group(9));
-    return new CalendarInterval((int) months, microseconds);
+    return new CalendarInterval((int) months, (int) days, microseconds);
 
 Review comment:
   I think it is better to catch int overflow by `Math.toIntExact` instead of silently ignore it.

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