[fix](Nereids) array_intersect should be a variadic function (#34543)

This commit is contained in:
morrySnow
2024-05-09 10:22:30 +08:00
committed by yiguolei
parent 5271042a7d
commit 391dc35e17

View File

@ -21,10 +21,10 @@ import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.ArrayType;
import org.apache.doris.nereids.types.coercion.AnyDataType;
import org.apache.doris.nereids.util.ExpressionUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
@ -34,19 +34,18 @@ import java.util.List;
/**
* ScalarFunction 'array_intersect'. This class is generated by GenerateFunction.
*/
public class ArrayIntersect extends ScalarFunction implements ExplicitlyCastableSignature,
BinaryExpression, PropagateNullable {
public class ArrayIntersect extends ScalarFunction implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.retArgType(0)
.args(ArrayType.of(new AnyDataType(0)), ArrayType.of(new AnyDataType(0)))
.varArgs(ArrayType.of(new AnyDataType(0)), ArrayType.of(new AnyDataType(0)))
);
/**
* constructor with 2 arguments.
* constructor with 2 or more arguments.
*/
public ArrayIntersect(Expression arg0, Expression arg1) {
super("array_intersect", arg0, arg1);
public ArrayIntersect(Expression arg0, Expression arg1, Expression... varArgs) {
super("array_intersect", ExpressionUtils.mergeArguments(arg0, arg1, varArgs));
}
/**
@ -54,8 +53,9 @@ public class ArrayIntersect extends ScalarFunction implements ExplicitlyCastable
*/
@Override
public ArrayIntersect withChildren(List<Expression> children) {
Preconditions.checkArgument(children.size() == 2);
return new ArrayIntersect(children.get(0), children.get(1));
Preconditions.checkArgument(children.size() >= 2);
return new ArrayIntersect(children.get(0), children.get(1),
children.subList(2, children.size()).toArray(new Expression[0]));
}
@Override