Kikyou1997 commented on code in PR #13883:
URL: https://github.com/apache/doris/pull/13883#discussion_r1013619306
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/stats/FilterEstimation.java:
##########
@@ -108,30 +121,31 @@ public StatsDeriveResult
visitComparisonPredicate(ComparisonPredicate cp, Estima
boolean isNot = (context != null) && context.isNot;
Expression left = cp.left();
Expression right = cp.right();
- ColumnStat statsForLeft = ExpressionEstimation.estimate(left,
inputStats);
- ColumnStat statsForRight = ExpressionEstimation.estimate(right,
inputStats);
-
+ ColumnStatistic statsForLeft = ExpressionEstimation.estimate(left,
inputStats);
+ ColumnStatistic statsForRight = ExpressionEstimation.estimate(right,
inputStats);
+ ColumnStatisticBuilder leftBuilder = new
ColumnStatisticBuilder(statsForLeft);
double selectivity;
if (!(left instanceof Literal) && !(right instanceof Literal)) {
selectivity = calculateWhenBothChildIsColumn(cp, statsForLeft,
statsForRight);
} else {
// For literal, it's max min is same value.
selectivity = updateLeftStatsWhenRightChildIsLiteral(cp,
- statsForLeft,
- statsForRight.getMaxValue(),
+ leftBuilder,
+ statsForRight.maxValue,
isNot);
}
StatsDeriveResult outputStats = new StatsDeriveResult(inputStats);
//TODO: we take the assumption that func(A) and A have the same stats.
- outputStats.updateBySelectivity(selectivity, cp.getInputSlots());
+
if (left.getInputSlots().size() == 1) {
Slot leftSlot = left.getInputSlots().iterator().next();
- outputStats.updateColumnStatsForSlot(leftSlot, statsForLeft);
+ outputStats.addColumnStats(leftSlot.getExprId(),
leftBuilder.createColumnStatistic());
}
- return outputStats;
+ return outputStats.updateBySelectivity(selectivity,
+
cp.getInputSlots().stream().map(Slot::getExprId).collect(Collectors.toSet()));
}
- private double updateLessThan(ColumnStat statsForLeft, double val,
+ private double updateLessThan(ColumnStatisticBuilder statsForLeft, double
val,
Review Comment:
in the caller
--
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]