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_r352439282
##########
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:
Based on math, if you use max_long / milliseoncd_per_day, the number will
still exceed int_max. So technically overflow exists.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services