Skip to content

Commit

Permalink
estimate is-null
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Sep 22, 2023
1 parent 0d20a61 commit dd8a304
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.doris.nereids.trees.expressions.GreaterThan;
import org.apache.doris.nereids.trees.expressions.GreaterThanEqual;
import org.apache.doris.nereids.trees.expressions.InPredicate;
import org.apache.doris.nereids.trees.expressions.IsNull;
import org.apache.doris.nereids.trees.expressions.LessThan;
import org.apache.doris.nereids.trees.expressions.LessThanEqual;
import org.apache.doris.nereids.trees.expressions.Like;
Expand Down Expand Up @@ -386,6 +387,19 @@ public Statistics visitNot(Not not, EstimationContext context) {
return statisticsBuilder.build();
}

@Override
public Statistics visitIsNull(IsNull isNull, EstimationContext context) {
ColumnStatistic childStats = ExpressionEstimation.estimate(isNull.child(), context.statistics);
if (childStats.isUnKnown()) {
return new StatisticsBuilder(context.statistics).build();
}
double outputRowCount = context.statistics.getRowCount() - childStats.numNulls;
StatisticsBuilder builder = new StatisticsBuilder(context.statistics);
builder.putColumnStatistics(isNull.child(), childStats);
Statistics outputStats = builder.build().updateRowCountOnly(outputRowCount);
return outputStats;
}

static class EstimationContext {
private final Statistics statistics;

Expand Down

0 comments on commit dd8a304

Please sign in to comment.