Skip to content

Commit

Permalink
[nereids] consider numNulls in filter estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongjian.xzj authored and zhongjian.xzj committed Dec 29, 2023
1 parent 3c5d5ac commit 0f692eb
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ private Statistics estimateEqualTo(ComparisonPredicate cp, ColumnStatistic stats
double val = statsForRight.maxValue;
if (val > statsForLeft.maxValue || val < statsForLeft.minValue) {
selectivity = 0.0;
} else if (statsForRight.isUnKnown) {
selectivity = 0.0;
} else {
selectivity = StatsMathUtil.minNonNaN(1.0, 1.0 / ndv);
}
Expand Down Expand Up @@ -581,9 +579,10 @@ public Statistics visitLike(Like like, EstimationContext context) {
"col stats not found. slot=%s in %s",
like.left().toSql(), like.toSql());
ColumnStatisticBuilder colBuilder = new ColumnStatisticBuilder(origin);
double selectivity = origin.ndv * DEFAULT_LIKE_COMPARISON_SELECTIVITY;
double selectivity = StatsMathUtil.divide(DEFAULT_LIKE_COMPARISON_SELECTIVITY, origin.ndv);
double notNullSel = getNotNullSelectivity(origin, selectivity);
colBuilder.setNdv(selectivity).setCount(notNullSel * context.statistics.getRowCount()).setNumNulls(0);
colBuilder.setNdv(origin.ndv * DEFAULT_LIKE_COMPARISON_SELECTIVITY)
.setCount(notNullSel * context.statistics.getRowCount()).setNumNulls(0);
statsBuilder.putColumnStatistics(like.left(), colBuilder.build());
context.addKeyIfSlot(like.left());
}
Expand Down

0 comments on commit 0f692eb

Please sign in to comment.