Skip to content

Commit

Permalink
[Fix](nereids) set all nullable aggregate function to alwaysnullable …
Browse files Browse the repository at this point in the history
…in window expression
  • Loading branch information
feiniaofeiafei committed Sep 11, 2024
1 parent d736a50 commit 87cee07
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
import org.apache.doris.nereids.trees.expressions.OrderExpression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.WindowExpression;
import org.apache.doris.nereids.trees.expressions.functions.agg.Avg;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
import org.apache.doris.nereids.trees.expressions.functions.agg.NullableAggregateFunction;
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import org.apache.doris.nereids.trees.plans.logical.LogicalWindow;
Expand Down Expand Up @@ -64,13 +60,11 @@ private Plan normalize(LogicalProject<Plan> project) {
if (output instanceof WindowExpression) {
WindowExpression windowExpression = (WindowExpression) output;
Expression expression = ((WindowExpression) output).getFunction();
if (expression instanceof Sum || expression instanceof Max
|| expression instanceof Min || expression instanceof Avg) {
// sum, max, min and avg in window function should be always nullable
windowExpression = ((WindowExpression) output)
.withFunction(
((NullableAggregateFunction) expression).withAlwaysNullable(true)
);
if (expression instanceof NullableAggregateFunction) {
// NullableAggregateFunction in window function should be always nullable
// Because there may be no data in the window frame, null values will be generated.
windowExpression = ((WindowExpression) output).withFunction(
((NullableAggregateFunction) expression).withAlwaysNullable(true));
}

ImmutableList.Builder<Expression> nonLiteralPartitionKeys =
Expand Down

0 comments on commit 87cee07

Please sign in to comment.