konstantinb commented on code in PR #6505:
URL: https://github.com/apache/hive/pull/6505#discussion_r4724579448
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/FilterSelectivityEstimator.java:
##########
@@ -74,6 +74,7 @@ public class FilterSelectivityEstimator extends
RexVisitorImpl<Double> {
private final double childCardinality;
private final RelMetadataQuery mq;
private final RexBuilder rexBuilder;
+ private boolean unknownSeen;
Review Comment:
Thanks, done in
[3241f0c](https://github.com/apache/hive/pull/6505/commits/3241f0ce0754439f7ebd713c6204b0da536770b9).
`unknownSeen` is gone; `FilterSelectivityEstimator` now takes an immutable
`propagateUnknown` flag. Only the filter-above-anti-join estimate in
`HiveRelMdSelectivity` uses it, since that is the only place that inverts the
estimate (`1 - selectivity`).
The flag also covers OR (multi-range SEARCH shares that code): OR treats an
unknown part as 0.99, which the inversion turns into about 0.01. With only AND
propagating, the existing LIMIT + OR case in `cbo_ndv_unknown_estimates.q`
drops from 300 rows to 3 (actual 298). I added an AND case next to it: 300
rows, actual 296; without the AND branch it would be 1.2.
I kept null rather than zero: Calcite floors a 0 NDV to 1, so an unknown key
would again look like a single distinct value (GROUP BY on an unknown key: 1
row with zero, 50 now, actual 309).
Agreed that the inversion itself is the real inconsistency. It is
pre-existing on master (the disabled
`knownFilterAboveAntiJoinKeepsItsSelectivity` test documents it), so I'd handle
it in a separate JIRA.
--
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]