diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Covar.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Covar.java index 2bebde3b4e..6d7707dc31 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Covar.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Covar.java @@ -19,7 +19,6 @@ package org.apache.doris.nereids.trees.expressions.functions.agg; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.nereids.trees.expressions.Expression; -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.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; @@ -38,8 +37,8 @@ import java.util.List; /** * AggregateFunction 'covar'. This class is generated by GenerateFunction. */ -public class Covar extends AggregateFunction - implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { +public class Covar extends NullableAggregateFunction + implements UnaryExpression, ExplicitlyCastableSignature { public static final List SIGNATURES = ImmutableList.of( FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, DoubleType.INSTANCE), @@ -54,14 +53,18 @@ public class Covar extends AggregateFunction * constructor with 2 argument. */ public Covar(Expression arg1, Expression arg2) { - super("covar", arg1, arg2); + this(false, arg1, arg2); } /** * constructor with 3 arguments. */ public Covar(boolean distinct, Expression arg1, Expression arg2) { - super("covar", distinct, arg1, arg2); + this(distinct, false, arg1, arg2); + } + + public Covar(boolean distinct, boolean alwaysNullable, Expression arg1, Expression arg2) { + super("covar", distinct, alwaysNullable, arg1, arg2); } /** @@ -70,7 +73,12 @@ public class Covar extends AggregateFunction @Override public Covar withDistinctAndChildren(boolean distinct, List children) { Preconditions.checkArgument(children.size() == 2); - return new Covar(distinct, children.get(0), children.get(1)); + return new Covar(distinct, alwaysNullable, children.get(0), children.get(1)); + } + + @Override + public Covar withAlwaysNullable(boolean alwaysNullable) { + return new Covar(distinct, alwaysNullable, children.get(0), children.get(1)); } @Override diff --git a/regression-test/data/nereids_function_p0/agg_function/test_covar.out b/regression-test/data/nereids_function_p0/agg_function/test_covar.out index 770e620ef7..3616b8e4a9 100644 --- a/regression-test/data/nereids_function_p0/agg_function/test_covar.out +++ b/regression-test/data/nereids_function_p0/agg_function/test_covar.out @@ -10,3 +10,22 @@ -- !sql -- 3.5 + +-- !sql_input_nullable_without_key -- +3.5 + +-- !sql_input_nullable_with_key -- +0.0 +0.0 +0.0 +0.0 + +-- !sql_input_non_nullable_without_key -- +3.5 + +-- !sql_input_nullable_with_key -- +0.0 +0.0 +0.0 +0.0 + diff --git a/regression-test/suites/nereids_function_p0/agg_function/test_covar.groovy b/regression-test/suites/nereids_function_p0/agg_function/test_covar.groovy index 2416b88fa5..fe1a47b97d 100644 --- a/regression-test/suites/nereids_function_p0/agg_function/test_covar.groovy +++ b/regression-test/suites/nereids_function_p0/agg_function/test_covar.groovy @@ -77,6 +77,19 @@ suite("test_covar") { (4, 4, 10) """ qt_sql "select covar(x,y) from test_covar" - - sql """ DROP TABLE IF EXISTS test_covar """ + + qt_sql_input_nullable_without_key """ + select covar(x,y) from test_covar; + """ + qt_sql_input_nullable_with_key """ + select covar(x,y) from test_covar group by id order by id; + """ + + qt_sql_input_non_nullable_without_key """ + select covar(non_nullable(x),non_nullable(y)) from test_covar; + """ + + qt_sql_input_nullable_with_key """ + select covar(non_nullable(x),non_nullable(y)) from test_covar group by id order by id; + """ }