You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/02/11 22:46:36 UTC

[GitHub] [druid] gianm commented on a change in pull request #9337: Fix timestamp extract fn to match postgreSQL

gianm commented on a change in pull request #9337: Fix timestamp extract fn to match postgreSQL
URL: https://github.com/apache/druid/pull/9337#discussion_r377945477
 
 

 ##########
 File path: processing/src/main/java/org/apache/druid/query/expression/TimestampExtractExprMacro.java
 ##########
 @@ -141,13 +141,13 @@ public ExprEval eval(final ObjectBinding bindings)
             return ExprEval.of(dateTime.year().get());
           case DECADE:
             // The year field divided by 10, See https://www.postgresql.org/docs/10/functions-datetime.html
-            return ExprEval.of(Math.floor(dateTime.year().get() / 10));
+            return ExprEval.of(dateTime.year().get() / 10);
           case CENTURY:
-            return ExprEval.of(dateTime.centuryOfEra().get() + 1);
+            return ExprEval.of(Math.ceil((double) dateTime.year().get() / 100));
           case MILLENNIUM:
             // Years in the 1900s are in the second millennium. The third millennium started January 1, 2001.
             // See https://www.postgresql.org/docs/10/functions-datetime.html
-            return ExprEval.of(Math.round(Math.ceil(dateTime.year().get() / 1000)));
+            return ExprEval.of(Math.round(Math.ceil((double) dateTime.year().get() / 1000)));
 
 Review comment:
   Could it be suppressed in that one location?

----------------------------------------------------------------
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: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org