This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 1259fe2bd58 [fix](covar) Fix covar nullable on branch-2.1 (#40841)
1259fe2bd58 is described below

commit 1259fe2bd58d5075b9b1b05bec30d2c47a91272c
Author: zhiqiang <seuhezhiqi...@163.com>
AuthorDate: Fri Sep 20 17:35:27 2024 +0800

    [fix](covar) Fix covar nullable on branch-2.1 (#40841)
    
    covar should not be always nullable.
    
    This fix on branch-2.1 makes covar same with master on FE.
---
 .../trees/expressions/functions/agg/Covar.java       | 20 ++++++++++++++------
 .../nereids_function_p0/agg_function/test_covar.out  | 19 +++++++++++++++++++
 .../agg_function/test_covar.groovy                   | 17 +++++++++++++++--
 3 files changed, 48 insertions(+), 8 deletions(-)

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 2bebde3b4ed..6d7707dc31f 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<FunctionSignature> 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<Expression> 
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 770e620ef71..3616b8e4a9f 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 2416b88fa5e..fe1a47b97d0 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;
+    """
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to