This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 916da87fc05 branch-3.0: [fix](nereids) fix sum0 cannot pass multi
distinct check #51234 (#52950)
916da87fc05 is described below
commit 916da87fc053a4ef958521fff951fd45fcaee0b1
Author: feiniaofeiafei <[email protected]>
AuthorDate: Wed Jul 9 16:07:11 2025 +0800
branch-3.0: [fix](nereids) fix sum0 cannot pass multi distinct check #51234
(#52950)
cherry-pick #51234 to branch-3.0
---
.../doris/nereids/rules/rewrite/CheckMultiDistinct.java | 3 ++-
regression-test/data/nereids_syntax_p0/analyze_agg.out | Bin 107 -> 185 bytes
.../suites/nereids_syntax_p0/analyze_agg.groovy | 11 +++++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMultiDistinct.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMultiDistinct.java
index 4488a94b8d1..588d11a41df 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMultiDistinct.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CheckMultiDistinct.java
@@ -25,6 +25,7 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.Avg;
import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.agg.GroupConcat;
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.agg.Sum0;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
@@ -41,7 +42,7 @@ import com.google.common.collect.ImmutableSet;
*/
public class CheckMultiDistinct extends OneRewriteRuleFactory {
private final ImmutableSet<Class<? extends AggregateFunction>>
supportedFunctions =
- ImmutableSet.of(Count.class, Sum.class, Avg.class,
GroupConcat.class);
+ ImmutableSet.of(Count.class, Sum.class, Avg.class,
GroupConcat.class, Sum0.class);
@Override
public Rule build() {
diff --git a/regression-test/data/nereids_syntax_p0/analyze_agg.out
b/regression-test/data/nereids_syntax_p0/analyze_agg.out
index 9c9c4c6c8a2..8316c4aefe2 100644
Binary files a/regression-test/data/nereids_syntax_p0/analyze_agg.out and
b/regression-test/data/nereids_syntax_p0/analyze_agg.out differ
diff --git a/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy
b/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy
index 9a79df6bad5..cf93cad471c 100644
--- a/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy
+++ b/regression-test/suites/nereids_syntax_p0/analyze_agg.groovy
@@ -88,4 +88,15 @@ suite("analyze_agg") {
1,
x
"""
+
+ sql "drop table if exists test_sum0_multi_distinct_with_group_by"
+ sql "create table test_sum0_multi_distinct_with_group_by (a int, b int, c
int) distributed by hash(a) properties('replication_num'='1');"
+ sql """
+ INSERT INTO test_sum0_multi_distinct_with_group_by VALUES
+ (1, NULL, 3), (2, NULL, 5), (3, NULL, 7),
+ (4,5,6),(4,5,7),(4,5,8),
+ (5,0,0),(5,0,0),(5,0,0);
+ """
+ qt_test_sum0 "select sum0(distinct b),sum(distinct c) from
test_sum0_multi_distinct_with_group_by group by a order by 1,2"
+ qt_test_sum0_all_null "select sum0(distinct b),sum(distinct c) from
test_sum0_multi_distinct_with_group_by where a in (1,2,3) group by a order by
1,2"
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]