zabetak commented on code in PR #6293:
URL: https://github.com/apache/hive/pull/6293#discussion_r2874013575
##########
ql/src/test/org/apache/hadoop/hive/ql/optimizer/calcite/stats/TestFilterSelectivityEstimator.java:
##########
@@ -726,7 +761,85 @@ public void testRangePredicateOnDateWithCast() {
}
@Test
- public void testBetweenWithCastDecimal2s1() {
+ public void testBetweenWithCastToTinyIntCheckRounding() {
+ useFieldWithValues("f_numeric", VALUES3, KLL3);
+ float total = VALUES3.length;
+ float universe = 10; // the number of values that "survive" the cast
+ RexNode cast = cast("f_numeric", TINYINT);
+ // check rounding of positive numbers
+ checkBetweenSelectivity(3, universe, total, cast, 0, 10);
+ checkBetweenSelectivity(3, universe, total, cast, 0, 10.9f);
Review Comment:
```sql
EXPLAIN CBO SELECT e FROM tab3 WHERE CAST(e as SMALLINT) BETWEEN 10.9999 AND
20
```
The CBO plan from a query similar to the one you cited is shown below
```
CBO PLAN:
HiveProject(e=[$0])
HiveFilter(condition=[BETWEEN(false, CAST(CAST($0):SMALLINT):DECIMAL(14,
4), 10.9999:DECIMAL(14, 4), 20:DECIMAL(14, 4))])
HiveTableScan(table=[[default, tab3]], table:alias=[tab3])
```
The BETWEEN expression does not seem to be the same with the one that we are
creating and passing in the selectivity estimator. Note that there are two
`CAST` wrapped around the input column and in the end everything is casted to
`DECIMAL` type in order to perform the comparison.
--
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]