You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/12/01 06:18:16 UTC

[GitHub] [calcite] amaliujia commented on a change in pull request #1618: [hotfix] Fixed an issue where overflow from Long to Int was unsafe

amaliujia commented on a change in pull request #1618: [hotfix] Fixed an issue where overflow from Long to Int was unsafe
URL: https://github.com/apache/calcite/pull/1618#discussion_r352322463
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rex/RexInterpreter.java
 ##########
 @@ -213,7 +213,7 @@ private Comparable extract(RexCall call, List<Comparable> values) {
     final int v2;
     if (v instanceof Long) {
       // TIMESTAMP
-      v2 = (int) (((Long) v) / TimeUnit.DAY.multiplier.longValue());
+      v2 = Math.toIntExact(((Long) v) / TimeUnit.DAY.multiplier.longValue());
 
 Review comment:
   One think I don't understand here is `v2` is still used as `long` in the following code `DateTimeUtils.unixDateExtract(timeUnitRange, v2);`. Maybe the right fix is do not do long -> int conversion?

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