deniskuzZ commented on code in PR #5637:
URL: https://github.com/apache/hive/pull/5637#discussion_r2166549007


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java:
##########
@@ -1130,16 +1130,19 @@ private long evaluateComparator(Statistics stats, 
AnnotateStatsProcCtx aspCtx, E
               }
             }
           } else if (colTypeLowerCase.equals(serdeConstants.INT_TYPE_NAME) ||
-              colTypeLowerCase.equals(serdeConstants.DATE_TYPE_NAME)) {
-            int value;
+              colTypeLowerCase.equals(serdeConstants.DATE_TYPE_NAME) ||
+              colTypeLowerCase.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) {
+            long value;
             if (colTypeLowerCase.equals(serdeConstants.DATE_TYPE_NAME)) {
               DateWritable writableVal = new 
DateWritable(java.sql.Date.valueOf(boundValue));
               value = writableVal.getDays();
+            } else if 
(colTypeLowerCase.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) {
+              TimestampWritableV2 timestampWritable = new 
TimestampWritableV2(Timestamp.valueOf(boundValue));
+              value = timestampWritable.getTimestamp().toEpochSecond();
             } else {
               value = Integer.parseInt(boundValue);
             }
-            // Date is an integer internally
-            int maxValue = cs.getRange().maxValue.intValue();
+            long maxValue = cs.getRange().maxValue.longValue();
             int minValue = cs.getRange().minValue.intValue();

Review Comment:
   @kasakrisz we need to use long for `maxValue` to avoid overflow when we 
evaluate (maxValue-minValue). INT_TYPE: `Integer.MAX_VALUE` - 
`Integer.MIN_VALUE` = 2x`Integer.MAX_VALUE`
   Additionally, I moved here `TIMESTAMP_TYPE` with maxValue of Long range. 
Note it's minValue is always positive, so there won't be overflow. 



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

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to