[fix](nereids)fix nullable property of ForEachCombinator (#37980)
## Proposed changes pick from master https://github.com/apache/doris/pull/37796 <!--Describe your changes.-->
This commit is contained in:
@ -20,9 +20,9 @@ package org.apache.doris.nereids.trees.expressions.functions.combinator;
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AggCombinerFunctionBuilder;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.agg.NullableAggregateFunction;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.ArrayType;
|
||||
@ -36,8 +36,8 @@ import java.util.Objects;
|
||||
/**
|
||||
* combinator foreach
|
||||
*/
|
||||
public class ForEachCombinator extends AggregateFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable, Combinator {
|
||||
public class ForEachCombinator extends NullableAggregateFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, Combinator {
|
||||
|
||||
private final AggregateFunction nested;
|
||||
|
||||
@ -45,7 +45,11 @@ public class ForEachCombinator extends AggregateFunction
|
||||
* constructor of ForEachCombinator
|
||||
*/
|
||||
public ForEachCombinator(List<Expression> arguments, AggregateFunction nested) {
|
||||
super(nested.getName() + AggCombinerFunctionBuilder.FOREACH_SUFFIX, arguments);
|
||||
this(arguments, false, nested);
|
||||
}
|
||||
|
||||
public ForEachCombinator(List<Expression> arguments, boolean alwaysNullable, AggregateFunction nested) {
|
||||
super(nested.getName() + AggCombinerFunctionBuilder.FOREACH_SUFFIX, false, alwaysNullable, arguments);
|
||||
|
||||
this.nested = Objects.requireNonNull(nested, "nested can not be null");
|
||||
}
|
||||
@ -56,7 +60,7 @@ public class ForEachCombinator extends AggregateFunction
|
||||
|
||||
@Override
|
||||
public ForEachCombinator withChildren(List<Expression> children) {
|
||||
return new ForEachCombinator(children, nested);
|
||||
return new ForEachCombinator(children, alwaysNullable, nested);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,4 +92,9 @@ public class ForEachCombinator extends AggregateFunction
|
||||
public AggregateFunction withDistinctAndChildren(boolean distinct, List<Expression> children) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'withDistinctAndChildren'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NullableAggregateFunction withAlwaysNullable(boolean alwaysNullable) {
|
||||
return new ForEachCombinator(children, alwaysNullable, nested);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ public interface AggregateFunctionVisitor<R, C> {
|
||||
}
|
||||
|
||||
default R visitForEachCombinator(ForEachCombinator combinator, C context) {
|
||||
return visitAggregateFunction(combinator, context);
|
||||
return visitNullableAggregateFunction(combinator, context);
|
||||
}
|
||||
|
||||
default R visitJavaUdaf(JavaUdaf javaUdaf, C context) {
|
||||
|
||||
Reference in New Issue
Block a user