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/07/03 04:11:19 UTC

[GitHub] [spark] dongjoon-hyun commented on a change in pull request #25000: [SPARK-28107][SQL] Support 'day to hour', 'day to minute', 'hour to minute' and 'minute to second'

dongjoon-hyun commented on a change in pull request #25000: [SPARK-28107][SQL] Support 'day to hour', 'day to minute', 'hour to minute' and 'minute to second'
URL: https://github.com/apache/spark/pull/25000#discussion_r299769788
 
 

 ##########
 File path: common/unsafe/src/main/java/org/apache/spark/unsafe/types/CalendarInterval.java
 ##########
 @@ -174,11 +179,41 @@ public static CalendarInterval fromDayTimeString(String s) throws IllegalArgumen
         int sign = m.group(1) != null && m.group(1).equals("-") ? -1 : 1;
         long days = m.group(2) == null ? 0 : toLongWithRange("day", m.group(3),
           0, Integer.MAX_VALUE);
-        long hours = toLongWithRange("hour", m.group(4), 0, 23);
-        long minutes = toLongWithRange("minute", m.group(5), 0, 59);
-        long seconds = toLongWithRange("second", m.group(6), 0, 59);
+        long hours;
+        long minutes;
+        long seconds;
+        switch (from) {
+          case "minute":
+            hours = m.group(6) == null ? 0 : toLongWithRange("hour", m.group(4), 0, 23);
+            minutes = m.group(6) == null ? toLongWithRange("minute", m.group(4), 0, 59)
+              : toLongWithRange("minute", m.group(5), 0, 59);
+            seconds = m.group(6) == null ? toLongWithRange("minute", m.group(5), 0, 59)
+              : toLongWithRange("second", m.group(7), 0, 59);
+            break;
+          default:
 
 Review comment:
   If we have only two cases, please use `if ... else`.

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