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 18:57:53 UTC

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

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

 ##########
 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:
   You don't need Math.round if the result is already Math.ceil since Math.ceil returns int

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