thomasrebele commented on code in PR #6189:
URL: https://github.com/apache/hive/pull/6189#discussion_r2533440562
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/stats/annotation/StatsRulesProcFactory.java:
##########
@@ -1285,15 +1285,20 @@ private long
evaluateComparatorWithHistogram(ColStatistics cs, long currNumRows,
try {
final float value = extractFloatFromLiteralValue(colTypeLowerCase,
boundValue);
- // kll ignores null values (i.e., kll.getN() + numNulls =
currNumRows), we therefore need to use kll.getN()
- // instead of currNumRows since the CDF is expressed as a fraction of
kll.getN(), not currNumRows
+ double rawSelectivity;
if (upperBound) {
- return Math.round(kll.getN() * (closedBound ?
- lessThanOrEqualSelectivity(kll, value) :
lessThanSelectivity(kll, value)));
+ rawSelectivity = (closedBound ?
+ lessThanOrEqualSelectivity(kll, value) :
lessThanSelectivity(kll, value));
} else {
- return Math.round(kll.getN() * (closedBound ?
- greaterThanOrEqualSelectivity(kll, value) :
greaterThanSelectivity(kll, value)));
+ rawSelectivity = (closedBound ?
+ greaterThanOrEqualSelectivity(kll, value) :
greaterThanSelectivity(kll, value));
}
+
+ // kll ignores null values (i.e., kll.getN() + numNulls = total number
of rows),
+ // so the above rawSelectivity refers to count/kll.getN()
+ // what we need is the selectivity count/(total number of rows)
+ double totalSelectivity = (kll.getN() * rawSelectivity) / (kll.getN()
+ cs.getNumNulls());
Review Comment:
I think the original is clearer, as `count = kll.getN() * rawSelecitvity`,
and then just put it into `count/(total number of rows)`.
--
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]