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

morningman 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 dccd04a3ba [fix](fe)predicate is wrongly pushed through CUBE function 
(#15831)
dccd04a3ba is described below

commit dccd04a3bab079a6e26ec724d49008d7a8199e52
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Feb 6 11:29:15 2023 +0800

    [fix](fe)predicate is wrongly pushed through CUBE function (#15831)
---
 .../org/apache/doris/planner/SingleNodePlanner.java    |  9 ++++-----
 .../data/query_p0/grouping_sets/test_grouping_sets.out |  3 +++
 .../query_p0/grouping_sets/test_grouping_sets.groovy   | 18 ++++++++++++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

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 72fbd85979..1003991f46 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
@@ -2667,8 +2667,10 @@ public class SingleNodePlanner {
                     //eg: select distinct c from ( select distinct c from 
table) t where c > 1;
                     continue;
                 }
-                if (stmt.getGroupByClause().isGroupByExtension()
-                        && 
stmt.getGroupByClause().getGroupingExprs().contains(sourceExpr)) {
+
+                if (sourceExpr.getFn() instanceof AggregateFunction) {
+                    isAllSlotReferToGroupBys = false;
+                } else if (stmt.getGroupByClause().isGroupByExtension()) {
                     // if grouping type is CUBE or ROLLUP will definitely 
produce null
                     if (stmt.getGroupByClause().getGroupingType() == 
GroupByClause.GroupingType.CUBE
                             || stmt.getGroupByClause().getGroupingType() == 
GroupByClause.GroupingType.ROLLUP) {
@@ -2684,9 +2686,6 @@ public class SingleNodePlanner {
                         }
                     }
                 }
-                if (sourceExpr.getFn() instanceof AggregateFunction) {
-                    isAllSlotReferToGroupBys = false;
-                }
             }
 
             if (isAllSlotReferToGroupBys) {
diff --git a/regression-test/data/query_p0/grouping_sets/test_grouping_sets.out 
b/regression-test/data/query_p0/grouping_sets/test_grouping_sets.out
index f2da1d2f67..564103d871 100644
--- a/regression-test/data/query_p0/grouping_sets/test_grouping_sets.out
+++ b/regression-test/data/query_p0/grouping_sets/test_grouping_sets.out
@@ -49,3 +49,6 @@
 
 -- !select7 --
 
+-- !select8 --
+test   2
+
diff --git 
a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy 
b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
index 83e517de53..d0c28ea703 100644
--- a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
+++ b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
@@ -60,4 +60,22 @@ suite("test_grouping_sets") {
     }
 
    qt_select7 """ select k1,k2,sum(k3) from test_query_db.test where 1 = 2 
group by grouping sets((k1), (k1,k2)) """ 
+
+   qt_select8 """ WITH dt AS 
+                    (select 'test' as name,1 as score
+                    UNION
+                    all 
+                    SELECT 'test' AS name,1 AS score
+                    UNION
+                    all SELECT 'test2' AS name,12 AS score
+                    UNION
+                    all SELECT 'test2' AS name,12 AS score ) ,result_data AS 
+                    (SELECT name,
+                        sum(score) AS score
+                    FROM dt
+                    GROUP BY  CUBE(name))
+                SELECT *
+                FROM result_data
+                WHERE name = 'test';
+            """
 }


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

Reply via email to