Skip to content

Commit

Permalink
[Fix](function) fix wrong nullable signature of function corr (#39380)
Browse files Browse the repository at this point in the history
## 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
#37330 already changed the
implementation context
  • Loading branch information
zclllyybb authored Aug 15, 2024
1 parent 265bf9d commit 4acd695
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DoubleType.INSTANCE).args(TinyIntType.INSTANCE, TinyIntType.INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 4acd695

Please sign in to comment.