Skip to content

Commit

Permalink
[fix](nereids) bug: after is-null stats derive, other column stats ar…
Browse files Browse the repository at this point in the history
…e dropped (apache#37809)
  • Loading branch information
englefly authored Jul 17, 2024
1 parent 721ecbc commit 8e24d8f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,17 +832,24 @@ private Statistics computeFilter(Filter filter) {
Statistics isNullStats = computeGeneratedIsNullStats((LogicalJoin) plan, filter);
if (isNullStats != null) {
// overwrite the stats corrected as above before passing to filter estimation
stats = isNullStats;
Set<Expression> newConjuncts = filter.getConjuncts().stream()
.filter(e -> !(e instanceof IsNull))
.collect(Collectors.toSet());
if (newConjuncts.isEmpty()) {
return stats;
return isNullStats;
} else {
// overwrite the filter by removing is null and remain the others
filter = ((LogicalFilter<?>) filter).withConjunctsAndProps(newConjuncts,
((LogicalFilter<?>) filter).getGroupExpression(),
Optional.of(((LogicalFilter<?>) filter).getLogicalProperties()), plan);
// add update is-null related column stats for other predicate derive
StatisticsBuilder builder = new StatisticsBuilder(stats);
for (Expression expr : isNullStats.columnStatistics().keySet()) {
builder.putColumnStatistics(expr, isNullStats.findColumnStatistics(expr));
}
builder.setRowCount(isNullStats.getRowCount());
stats = builder.build();
stats.enforceValid();
}
}
}
Expand Down

0 comments on commit 8e24d8f

Please sign in to comment.