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/09 22:45:27 UTC

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

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

 ##########
 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:
   I thought about making this an error in our inspection profile, but `CachingCostBalancerStrategy` does this, and I'm afraid to make a change in that class given the potential implications around the balancer strategy. I'm un-aware of a way to simulate what impact changing that division would have, so I decided to leave it as is.

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