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


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java:
##########
@@ -1166,40 +1169,42 @@ private long evaluateComparator(Statistics stats, 
AnnotateStatsProcCtx aspCtx, E
                 return Math.round(((double) (maxValue - value) / (maxValue - 
minValue)) * currNumRows);
               }
             }
-          } else if (colTypeLowerCase.equals(serdeConstants.BIGINT_TYPE_NAME) 
||
-              colTypeLowerCase.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) {
-            long value;
-            if (colTypeLowerCase.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) {
-              TimestampWritableV2 timestampWritable = new 
TimestampWritableV2(Timestamp.valueOf(boundValue));
-              value = timestampWritable.getTimestamp().toEpochSecond();
-            } else {
-              value = Long.parseLong(boundValue);
-            }
-            long maxValue = cs.getRange().maxValue.longValue();
-            long minValue = cs.getRange().minValue.longValue();
+          } else if 
(colTypeLowerCase.startsWith(serdeConstants.DECIMAL_TYPE_NAME) ||
+              colTypeLowerCase.equals(serdeConstants.BIGINT_TYPE_NAME)) {
+            BigDecimal value = new BigDecimal(boundValue);
+            BigDecimal maxValue = new 
BigDecimal(cs.getRange().maxValue.toString());
+            BigDecimal minValue = new 
BigDecimal(cs.getRange().minValue.toString());
+            int minComparison = value.compareTo(minValue);
+            int maxComparison = value.compareTo(maxValue);

Review Comment:
   Hive 
[BIGINT](https://hive.apache.org/docs/latest/languagemanual-types_27838462/#numeric-types)
 (8-byte signed integer, from `-9,223,372,036,854,775,808` to 
`9,223,372,036,854,775,807`) is represented as Java `long` in various places in 
the code.
   Could you please move it to the long branch.



##########
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:
   Should `minValue` and `maxValue` have the same type? 



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