okumin commented on code in PR #6505:
URL: https://github.com/apache/hive/pull/6505#discussion_r4716432565
##########
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:
This mutable state might add complexity. Once unknownSeen becomes true, it
never resets, even when the visitor is used to estimate another expression
(though that might not happen). I suspect this state was introduced because we
sometimes (i.e., ANTI JOIN only) want to propagate unknown and sometimes do
not; there is likely a workaround for the inconsistency, and it looks like we
should fix the inconsistency ideally.
Fixing these inconsistencies may be out of scope for this ticket. If so, we
could keep the previous implementation and have HiveRelMdDistinctRowCount
return zero when the NDV is unknown. Compared with the existing Hive code, that
would at least prevent negative NDVs from reaching Calcite. We could handle
proper null propagation and consistent fallback behavior in a separate change.
> Zero sounds better than negatives anyway, though.
--
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]