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 fff92656c702b533bc62fbb1db3f7bc133d25596
Author: starocean999 <[email protected]>
AuthorDate: Mon Aug 28 17:10:13 2023 +0800

    [fix](planner)fix bug of pushing conjunct through agg node (#23483)
---
 .../apache/doris/planner/SingleNodePlanner.java    |  2 +-
 .../test_push_conjuncts_inlineview.groovy          | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index faeb6183c0..efaf52820e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -2762,7 +2762,7 @@ public class SingleNodePlanner {
                 while (sourceExpr instanceof SlotRef) {
                     SlotRef slotRef = (SlotRef) sourceExpr;
                     SlotDescriptor slotDesc = slotRef.getDesc();
-                    if (slotDesc.getSourceExprs().isEmpty()) {
+                    if (slotDesc.getSourceExprs().size() != 1) {
                         break;
                     }
                     sourceExpr = slotDesc.getSourceExprs().get(0);
diff --git 
a/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy 
b/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy
index 4eff132649..1276b58807 100644
--- 
a/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy
+++ 
b/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy
@@ -128,6 +128,28 @@ sql """
     WHERE dd.d1 IN ('-1');
 """
 
+explain {
+        sql("""SELECT max(b_key)
+            FROM 
+                (SELECT a_key,
+                    max(b_key) AS b_key
+                FROM 
+                    (SELECT a_key,
+                    max(b_key) AS b_key
+                    FROM push_conjunct_table
+                    GROUP BY  a_key
+                    UNION all 
+                    SELECT a_key,
+                    max(b_key) AS b_key
+                    FROM push_conjunct_table
+                    GROUP BY  a_key) t2
+                    GROUP BY  t2.a_key ) t
+                WHERE t.a_key = "abcd"
+            GROUP BY  t.a_key;""")
+        notContains "having"
+        contains "= 'abcd'"
+    }
+
  sql """ DROP TABLE IF EXISTS `push_conjunct_table` """
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to