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


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/FilterSelectivityEstimator.java:
##########
@@ -184,91 +189,383 @@ public Double visitCall(RexCall call) {
     return selectivity;
   }
 
+  /**
+   * Return whether the expression is a removable cast based on stats and type 
bounds.
+   *
+   * <p>
+   * In Hive, if a value cannot be represented by the cast, the result of the 
cast is NULL,
+   * and therefore cannot fulfill the predicate. So the possible range of the 
values
+   * is limited by the range of possible values of the type.
+   * </p>

Review Comment:
   The case of `TINYINT` to `SMALLINT` is covered by " if a value cannot be 
represented by the cast", or rather by its negation. As all values of `TINYINT` 
can be represented by the cast to `SMALLINT`, we can see it as a case of the 
first category, where all non-representable values are cast to NULL. It's just 
that with `TINYINT` to `SMALLINT` there are no non-representable values, so the 
condition is trivially true. I'll try to improve the wording a bit.



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