thomasrebele commented on code in PR #6293:
URL: https://github.com/apache/hive/pull/6293#discussion_r2872718749


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/FilterSelectivityEstimator.java:
##########
@@ -218,6 +218,27 @@ private boolean isRemovableCast(RexNode exp, HiveTableScan 
tableScan) {
       return false;
     }
 
+    SqlTypeName targetType = cast.getType().getSqlTypeName();
+    SqlTypeName sourceType = op0.getType().getSqlTypeName();
+
+    switch (sourceType) {
+    case TINYINT, SMALLINT, INTEGER, BIGINT:
+      // additional checks are needed
+      break;
+    case FLOAT, DOUBLE, DECIMAL, TIMESTAMP, DATE:
+      return true;
+    default:
+      // unknown type, do not remove the cast
+      return false;
+    }
+
+    // If the source type is completely within the target type, the cast is 
lossless

Review Comment:
   This check only applies when casting an integer type to another integer 
type, so we cannot move it before the check whether the column statistics are 
empty.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to