pnowojski commented on a change in pull request #6614: [FLINK-9432] [table] 
Support extract timeunit: DECADE, EPOCH, ISODOW, ISOYEAR…
URL: https://github.com/apache/flink/pull/6614#discussion_r220175187
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
 ##########
 @@ -719,7 +724,13 @@ public static long timestampStringToUnixDate(String s) {
        }
 
        public static long unixDateExtract(TimeUnitRange range, long date) {
-               return julianExtract(range, (int) date + EPOCH_JULIAN);
+               switch (range) {
+                       case EPOCH:
+                               // no need to extract year/month/day, just 
multiply
+                               return date * SECONDS_PER_DAY;
+                       default:
+                               return julianExtract(range, (int) date + 
EPOCH_JULIAN);
+               }
        }
 
        private static int julianExtract(TimeUnitRange range, int julian) {
 
 Review comment:
   I'm a little bit worried about the `julian` thing in this method name... I 
have a bad feeling that it supposed to be Gregorian calendar here...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to