konstantinb commented on code in PR #6505:
URL: https://github.com/apache/hive/pull/6505#discussion_r4742208952
##########
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, that clarifies it. To answer your original question ("Does it
require major surgery, or do existing tests go wrong?") with what we found: yes
to both. It took major surgery: null guards in four Calcite classes (PK-FK
analysis, the selectivity entry points, NOT and SEARCH), two new test classes,
and finally the anti-join-only mode you object to. Existing tests went wrong as
well: three existing nested-column-pruning goldens changed, and five cases in
this PR's own `TestHiveRelMdDistinctRowCount` that pinned 0.0 had to change.
Without the guards, a PK-FK join on RELY constraints also failed with an NPE.
Before I change anything, let me confirm the plan:
1. Revert the null work (45c29a0, 9cc9cfb, 85b3980, 3241f0c). The Calcite
stats classes then match eda2c8d93e exactly: `HiveRelMdDistinctRowCount`
returns 0.0 for an unknown or zero NDV, and there is no anti-join special case.
2. That also drops the null-safety fixes that came with it, including the
NOT/SEARCH handling and the lateral-view NPE fix (that NPE also happens on
master), and the tests added for them (`TestHiveRelMdRowCount`,
`TestHiveRelMdSelectivity`, `cbo_ndv_unknown_estimates.q`,
`cbo_ndv_unknown_pkfk.q`).
3. Regressions vs master: in our earlier comparison of master with the
zero-fallback revision, estimates matched in every measured case except one: an
IN list on an int column with a stored `numDVs = -1` fails on master with an
`AssertionError` and is estimated normally with the fallback. I'll re-run the
affected tests after the revert.
4. Consistent unknown propagation, including the anti-join behavior and the
inversion of filters above anti joins, goes to a separate ticket.
Does that match what you had in mind, or would you like any part of the null
work kept here?
--
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]