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

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

commit 7b032727966e78dc22ae12c7dddc35af27adc25f
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Sep 1 17:16:10 2023 +0800

    [fix](nereids) NormalizeAggregate may push redundant expr to child project 
node (#23700)
    
    NormalizeAggregate may push exprs to child project node. We need make sure 
there is no redundant expr in the pushed down expr list. This pr use 'Set' to 
make sure of that.
---
 .../org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java    | 3 ++-
 regression-test/suites/correctness_p0/test_avg.groovy                  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java
index 6a141dce7a..83cd652b8d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java
@@ -39,6 +39,7 @@ import com.google.common.collect.ImmutableList.Builder;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 import java.util.List;
 import java.util.Map;
@@ -119,7 +120,7 @@ public class NormalizeAggregate extends 
OneRewriteRuleFactory implements Normali
             // agg(output: sum(alias(a + 1)[#1])[#2], group_by: alias(a + 
1)[#1])
             // +-- project((a[#0] + 1)[#1])
             List<AggregateFunction> normalizedAggFuncs = 
groupByToSlotContext.normalizeToUseSlotRef(aggFuncs);
-            List<NamedExpression> bottomProjects = 
Lists.newArrayList(bottomGroupByProjects);
+            Set<NamedExpression> bottomProjects = 
Sets.newHashSet(bottomGroupByProjects);
             // TODO: if we have distinct agg, we must push down its children,
             //   because need use it to generate distribution enforce
             // step 1: split agg functions into 2 parts: distinct and not 
distinct
diff --git a/regression-test/suites/correctness_p0/test_avg.groovy 
b/regression-test/suites/correctness_p0/test_avg.groovy
index 9e46842687..5c2c8923d0 100644
--- a/regression-test/suites/correctness_p0/test_avg.groovy
+++ b/regression-test/suites/correctness_p0/test_avg.groovy
@@ -64,6 +64,7 @@ suite("test_avg") {
             );
         """
     sql "set enable_nereids_planner=true"
+    sql "set enable_fallback_to_original_planner=false;"
     qt_select2 """select avg(distinct k2), avg(distinct cast(k4 as largeint)) 
from avg_test;"""
     sql "set enable_nereids_planner=false"
     qt_select3 """select avg(distinct k2), avg(distinct cast(k4 as largeint)) 
from avg_test;"""


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

Reply via email to