This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new a540b7eb439 [fix](Nereids) multi_distinct_sum should inherit
NullableAggregateFunction (#28349)
a540b7eb439 is described below
commit a540b7eb43938a70155f2cd768b36584666f459b
Author: morrySnow <[email protected]>
AuthorDate: Thu Dec 14 19:27:06 2023 +0800
[fix](Nereids) multi_distinct_sum should inherit NullableAggregateFunction
(#28349)
---
.../functions/agg/MultiDistinctSum.java | 16 ++++++++---
.../data/nereids_syntax_p0/adjust_nullable.out | 2 ++
.../nereids_syntax_p0/adjust_nullable.groovy | 31 ++++++++++++++++++++++
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
index 8441e028289..b440d91a310 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MultiDistinctSum.java
@@ -20,7 +20,6 @@ package
org.apache.doris.nereids.trees.expressions.functions.agg;
import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.trees.expressions.Expression;
-import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import
org.apache.doris.nereids.trees.expressions.functions.ComputePrecisionForSum;
import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
@@ -35,7 +34,7 @@ import com.google.common.collect.ImmutableList;
import java.util.List;
/** MultiDistinctSum */
-public class MultiDistinctSum extends AggregateFunction implements
UnaryExpression, AlwaysNotNullable,
+public class MultiDistinctSum extends NullableAggregateFunction implements
UnaryExpression,
ExplicitlyCastableSignature, ComputePrecisionForSum, MultiDistinction {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
@@ -45,11 +44,15 @@ public class MultiDistinctSum extends AggregateFunction
implements UnaryExpressi
);
public MultiDistinctSum(Expression arg0) {
- super("multi_distinct_sum", true, arg0);
+ super("multi_distinct_sum", true, false, arg0);
}
public MultiDistinctSum(boolean distinct, Expression arg0) {
- super("multi_distinct_sum", true, arg0);
+ super("multi_distinct_sum", true, false, arg0);
+ }
+
+ public MultiDistinctSum(boolean distinct, boolean alwaysNullable,
Expression arg0) {
+ super("multi_distinct_sum", true, alwaysNullable, arg0);
}
@Override
@@ -64,6 +67,11 @@ public class MultiDistinctSum extends AggregateFunction
implements UnaryExpressi
return new Sum(getArgument(0)).getSignatures();
}
+ @Override
+ public NullableAggregateFunction withAlwaysNullable(boolean
alwaysNullable) {
+ return new MultiDistinctSum(distinct, alwaysNullable, children.get(0));
+ }
+
@Override
public MultiDistinctSum withDistinctAndChildren(boolean distinct,
List<Expression> children) {
Preconditions.checkArgument(children.size() == 1);
diff --git a/regression-test/data/nereids_syntax_p0/adjust_nullable.out
b/regression-test/data/nereids_syntax_p0/adjust_nullable.out
index 4c443b8493a..485b1414ead 100644
--- a/regression-test/data/nereids_syntax_p0/adjust_nullable.out
+++ b/regression-test/data/nereids_syntax_p0/adjust_nullable.out
@@ -4,3 +4,5 @@
2
3
+-- !distinct_sum --
+
diff --git a/regression-test/suites/nereids_syntax_p0/adjust_nullable.groovy
b/regression-test/suites/nereids_syntax_p0/adjust_nullable.groovy
index 5014dd7b1d6..24fb20d9aa2 100644
--- a/regression-test/suites/nereids_syntax_p0/adjust_nullable.groovy
+++ b/regression-test/suites/nereids_syntax_p0/adjust_nullable.groovy
@@ -64,5 +64,36 @@ suite("adjust_nullable") {
order by
subq_1.gid;
"""
+
+ sql """
+ drop table if exists table_7_undef_undef;
+ """
+ sql """
+ drop table if exists table_8_undef_undef;
+ """
+ sql """
+ create table table_7_undef_undef (`pk` int,`col_int_undef_signed` int
,`col_varchar_10__undef_signed` varchar(10) ,`col_varchar_1024__undef_signed`
varchar(1024) ) engine=olap distributed by hash(pk) buckets 10 properties(
'replication_num' = '1');
+ """
+ sql """
+ create table table_8_undef_undef (`pk` int,`col_int_undef_signed` int
,`col_varchar_10__undef_signed` varchar(10) ,`col_varchar_1024__undef_signed`
varchar(1024) ) engine=olap distributed by hash(pk) buckets 10 properties(
'replication_num' = '1');
+ """
+
+ sql """
+ insert into table_7_undef_undef values
(0,6,"didn't","was"),(1,1,"mean",'k'),(2,2,'i','i'),(3,null,'y','p'),(4,8,"you're","and"),(5,6,'i','o'),(6,null,"have","not");
+ """
+ sql """
+ insert into table_8_undef_undef values
(0,null,"one",'m'),(1,null,"got",'m'),(2,9,'m','b'),(3,null,"say",'p'),(4,null,'t',"yeah"),(5,null,'y',"because"),(6,null,"from",'q'),(7,null,"the","in");
+ """
+
+ qt_distinct_sum """
+ SELECT SUM( DISTINCT alias1 . `col_int_undef_signed` ) AS field1
FROM table_7_undef_undef AS alias1 LEFT JOIN table_8_undef_undef AS alias2
ON alias1 . `col_varchar_1024__undef_signed` = alias2 .
`col_varchar_1024__undef_signed` WHERE alias2 . `pk` >= alias2 .
`col_int_undef_signed` HAVING field1 <> 8 ORDER BY field1 , field1 ;
+ """
+
+ sql """
+ drop table if exists table_7_undef_undef;
+ """
+ sql """
+ drop table if exists table_8_undef_undef;
+ """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]