From 4acd69590da5fa685cafaf78148a48573e064218 Mon Sep 17 00:00:00 2001 From: zclllhhjj Date: Thu, 15 Aug 2024 14:10:09 +0800 Subject: [PATCH] [Fix](function) fix wrong nullable signature of function corr (#39380) ## Proposed changes Issue Number: close #xxx before `corr(nullable_x, nullable_y)` will core dump. not fixed. no need to patch in master because the refactor https://github.com/apache/doris/pull/37330 already changed the implementation context --- .../trees/expressions/functions/agg/Corr.java | 4 ++-- .../agg_function/test_corr.out | 21 +++++++++++++++++++ .../agg_function/test_corr.groovy | 5 ++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Corr.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Corr.java index 26f8a720c26d66..b88b54d1378132 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Corr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/Corr.java @@ -19,8 +19,8 @@ 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.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.BigIntType; @@ -39,7 +39,7 @@ * AggregateFunction 'corr'. This class is generated by GenerateFunction. */ public class Corr extends AggregateFunction - implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable { + implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable { public static final List SIGNATURES = ImmutableList.of( FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE, TinyIntType.INSTANCE), diff --git a/regression-test/data/nereids_function_p0/agg_function/test_corr.out b/regression-test/data/nereids_function_p0/agg_function/test_corr.out index c694f95ebec0ec..71293030ba8eb5 100644 --- a/regression-test/data/nereids_function_p0/agg_function/test_corr.out +++ b/regression-test/data/nereids_function_p0/agg_function/test_corr.out @@ -14,3 +14,24 @@ -- !sql -- 0.8944271909999159 +-- !sql1 -- +0.0 +0.0 +0.0 +0.0 +0.0 + +-- !sql2 -- +0.0 +0.0 +0.0 +0.0 +0.0 + +-- !sql3 -- +0.0 +0.0 +0.0 +0.0 +0.0 + diff --git a/regression-test/suites/nereids_function_p0/agg_function/test_corr.groovy b/regression-test/suites/nereids_function_p0/agg_function/test_corr.groovy index 09ed98fab06509..c752e8cb1334c4 100644 --- a/regression-test/suites/nereids_function_p0/agg_function/test_corr.groovy +++ b/regression-test/suites/nereids_function_p0/agg_function/test_corr.groovy @@ -82,5 +82,8 @@ suite("test_corr") { qt_sql "select corr(x,y) from test_corr" qt_sql "select corr(cast(x as float),cast(y as float)) from test_corr" - sql """ DROP TABLE IF EXISTS test_corr """ + + qt_sql1 "select corr(non_nullable(x), non_nullable(y)) ans from test_corr group by id order by ans" + qt_sql2 "select corr(x, non_nullable(y)) ans from test_corr group by id order by ans" + qt_sql3 "select corr(non_nullable(x), y) ans from test_corr group by id order by ans" }