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 8340f23946c [feat](nereids) add more rules to eliminate empty relation 
(#34997)
8340f23946c is described below

commit 8340f23946c0c8e40510ce937acd3342cb2e28b7
Author: minghong <engle...@gmail.com>
AuthorDate: Tue May 21 19:38:33 2024 +0800

    [feat](nereids) add more rules to eliminate empty relation (#34997)
    
    eliminate empty relations for following patterns:
    topn->empty
    sort->empty
    distribute->empty
    project->empty
---
 .../org/apache/doris/nereids/rules/RuleType.java   |   4 +
 .../rules/rewrite/EliminateEmptyRelation.java      |  38 +++++-
 .../nereids/rules/rewrite/EliminateLimit.java      |   6 +-
 .../doris/nereids/jobs/joinorder/TPCHTest.java     |   1 +
 .../rules/rewrite/EliminateGroupByTest.java        |  20 +--
 .../nereids/rules/rewrite/EliminateLimitTest.java  |   1 +
 .../nereids/rules/rewrite/EliminateSortTest.java   |   3 +
 .../org/apache/doris/nereids/util/PlanChecker.java |   5 +
 .../data/empty_relation/eliminate_empty.out        |   6 +-
 .../load_p0/insert/insert_select_empty_table.out   |   7 +-
 .../eliminate_empty/query10_empty.out              |   5 +
 .../suites/empty_relation/eliminate_empty.groovy   |   9 +-
 .../insert/insert_select_empty_table.groovy        |  31 ++---
 .../suites/nereids_p0/union/test_union.groovy      |   7 +-
 .../eliminate_nullaware_anti_join.groovy           |   7 +-
 .../eliminate_empty/query10_empty.groovy           | 150 +++++++++++++++++++++
 16 files changed, 247 insertions(+), 53 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index 3d950b5781f..b1101b7592b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -117,7 +117,11 @@ public enum RuleType {
     ELIMINATE_JOIN_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
     ELIMINATE_FILTER_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
     ELIMINATE_AGG_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
+    ELIMINATE_PROJECT_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
     ELIMINATE_UNION_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
+    ELIMINATE_TOPN_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
+    ELIMINATE_SORT_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
+
     ELIMINATE_INTERSECTION_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
     ELIMINATE_EXCEPT_ON_EMPTYRELATION(RuleTypeClass.REWRITE),
     INFER_PREDICATES(RuleTypeClass.REWRITE),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java
index 2c0f9116ca2..204499fd9b9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateEmptyRelation.java
@@ -19,6 +19,7 @@ package org.apache.doris.nereids.rules.rewrite;
 
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.UnaryNode;
 import org.apache.doris.nereids.trees.expressions.Alias;
 import org.apache.doris.nereids.trees.expressions.ExprId;
 import org.apache.doris.nereids.trees.expressions.NamedExpression;
@@ -51,11 +52,12 @@ public class EliminateEmptyRelation implements 
RewriteRuleFactory {
         return ImmutableList.of(
             // join->empty
             logicalJoin(any(), any())
-                .when(this::hasEmptyRelationChild)
-                .when(this::canReplaceJoinByEmptyRelation)
+                .when(join -> hasEmptyRelationChild(join) && 
canReplaceJoinByEmptyRelation(join)
+                        || bothChildrenEmpty(join))
                 .then(join -> new LogicalEmptyRelation(
-                    
ConnectContext.get().getStatementContext().getNextRelationId(),
-                    join.getOutput()))
+                            
ConnectContext.get().getStatementContext().getNextRelationId(),
+                            join.getOutput())
+                )
                 .toRule(RuleType.ELIMINATE_JOIN_ON_EMPTYRELATION),
             logicalFilter(logicalEmptyRelation())
                 .then(filter -> new LogicalEmptyRelation(
@@ -68,7 +70,13 @@ public class EliminateEmptyRelation implements 
RewriteRuleFactory {
                     
ConnectContext.get().getStatementContext().getNextRelationId(),
                     agg.getOutput())
                 ).toRule(RuleType.ELIMINATE_AGG_ON_EMPTYRELATION),
-
+            // proj->empty
+            logicalProject(logicalEmptyRelation())
+                    .thenApply(ctx -> {
+                        LogicalProject<? extends Plan> project = ctx.root;
+                        return new 
LogicalEmptyRelation(ConnectContext.get().getStatementContext().getNextRelationId(),
+                                project.getOutputs());
+                    }).toRule(RuleType.ELIMINATE_AGG_ON_EMPTYRELATION),
             // after BuildAggForUnion rule, union may have more than 2 
children.
             logicalUnion(multi()).then(union -> {
                 if (union.children().isEmpty()) {
@@ -116,6 +124,18 @@ public class EliminateEmptyRelation implements 
RewriteRuleFactory {
                     return null;
                 }
             }).toRule(RuleType.ELIMINATE_UNION_ON_EMPTYRELATION),
+            // topn->empty
+            logicalTopN(logicalEmptyRelation())
+                    .then(topn -> new LogicalEmptyRelation(
+                            
ConnectContext.get().getStatementContext().getNextRelationId(),
+                            topn.getOutput()))
+                            .toRule(RuleType.ELIMINATE_TOPN_ON_EMPTYRELATION),
+            // sort->empty
+            logicalSort(logicalEmptyRelation())
+                    .then(sort -> new LogicalEmptyRelation(
+                            
ConnectContext.get().getStatementContext().getNextRelationId(),
+                            sort.getOutput()))
+                    .toRule(RuleType.ELIMINATE_SORT_ON_EMPTYRELATION),
             // set intersect
             logicalIntersect(multi()).then(intersect -> {
                 List<Plan> emptyChildren = intersect.children().stream()
@@ -131,6 +151,10 @@ public class EliminateEmptyRelation implements 
RewriteRuleFactory {
                             intersect.getOutput());
                 }
             }).toRule(RuleType.ELIMINATE_INTERSECTION_ON_EMPTYRELATION),
+            // limit -> empty
+            logicalLimit(logicalEmptyRelation())
+                    .then(UnaryNode::child)
+                    .toRule(RuleType.ELIMINATE_LIMIT_ON_EMPTY_RELATION),
             // set except
             logicalExcept(multi()).then(except -> {
                 Plan first = except.child(0);
@@ -186,6 +210,10 @@ public class EliminateEmptyRelation implements 
RewriteRuleFactory {
         return join.left() instanceof EmptyRelation || join.right() instanceof 
EmptyRelation;
     }
 
+    private boolean bothChildrenEmpty(LogicalJoin<?, ?> join) {
+        return join.left() instanceof EmptyRelation && join.right() instanceof 
EmptyRelation;
+    }
+
     private boolean canReplaceJoinByEmptyRelation(LogicalJoin<?, ?> join) {
         return !join.isMarkJoin() && ((join.getJoinType() == 
JoinType.INNER_JOIN
             || join.getJoinType() == JoinType.LEFT_SEMI_JOIN
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateLimit.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateLimit.java
index 8fbfc13934d..b3d8cac3a1c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateLimit.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateLimit.java
@@ -19,7 +19,6 @@ package org.apache.doris.nereids.rules.rewrite;
 
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
-import org.apache.doris.nereids.trees.UnaryNode;
 import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
 import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation;
 
@@ -44,10 +43,7 @@ public class EliminateLimit implements RewriteRuleFactory {
                         .then(limit -> limit.getLimit() > 0 && 
limit.getOffset() == 0
                                 ? limit.child() : new 
LogicalEmptyRelation(StatementScopeIdGenerator.newRelationId(),
                                 limit.child().getOutput()))
-                        .toRule(RuleType.ELIMINATE_LIMIT_ON_ONE_ROW_RELATION),
-                logicalLimit(logicalEmptyRelation())
-                        .then(UnaryNode::child)
-                        .toRule(RuleType.ELIMINATE_LIMIT_ON_EMPTY_RELATION)
+                        .toRule(RuleType.ELIMINATE_LIMIT_ON_ONE_ROW_RELATION)
         );
     }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java
index 3e88ac73bd0..9eefe62ea82 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java
@@ -60,6 +60,7 @@ public class TPCHTest extends TPCHTestBase implements 
MemoPatternMatchSupported
         // o_orderstatus is smaller than o_orderdate, but o_orderstatus is not 
used in this sql
         // it is better to choose the column which is already used to 
represent count(*)
         PlanChecker.from(connectContext)
+                .disableNereidsRules("PRUNE_EMPTY_PARTITION")
                 .analyze(sql)
                 .rewrite()
                 .matches(
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
index 9c8c2babec7..0b6d2f199fc 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java
@@ -46,13 +46,12 @@ class EliminateGroupByTest extends TestWithFeService 
implements MemoPatternMatch
         //  -> select id, age as max(age) from t;
         String sql = "select id, max(age) from t group by id";
 
-        PlanChecker.from(connectContext)
+        PlanChecker cheker = PlanChecker.from(connectContext)
                 .analyze(sql)
-                .rewrite()
-                .matches(
-                        logicalProject().when(p -> 
p.getProjects().get(0).toSql().equals("id")
-                                && p.getProjects().get(1).toSql().equals("age 
AS `max(age)`"))
-                );
+                .rewrite();
+        cheker.matches(
+                        logicalEmptyRelation().when(p -> 
p.getProjects().get(0).toSql().equals("id")
+                                && p.getProjects().get(1).toSql().equals("age 
AS `max(age)`")));
     }
 
     @Test
@@ -64,7 +63,7 @@ class EliminateGroupByTest extends TestWithFeService 
implements MemoPatternMatch
                 .analyze(sql)
                 .rewrite()
                 .matches(
-                        logicalProject().when(p -> 
p.getProjects().get(0).toSql().equals("id")
+                        logicalEmptyRelation().when(p -> 
p.getProjects().get(0).toSql().equals("id")
                                 && p.getProjects().get(1).toSql().equals("age 
AS `min(age)`"))
                 );
     }
@@ -78,7 +77,7 @@ class EliminateGroupByTest extends TestWithFeService 
implements MemoPatternMatch
                 .analyze(sql)
                 .rewrite()
                 .matches(
-                        logicalProject().when(p -> 
p.getProjects().get(0).toSql().equals("id")
+                        logicalEmptyRelation().when(p -> 
p.getProjects().get(0).toSql().equals("id")
                                 && 
p.getProjects().get(1).toSql().equals("cast(age as BIGINT) AS `sum(age)`"))
                 );
     }
@@ -92,8 +91,9 @@ class EliminateGroupByTest extends TestWithFeService 
implements MemoPatternMatch
                 .analyze(sql)
                 .rewrite()
                 .matches(
-                        logicalProject().when(p -> 
p.getProjects().get(0).toSql().equals("id")
-                                && 
p.getProjects().get(1).toSql().equals("if(age IS NULL, 0, 1) AS `if(age IS 
NULL, 0, 1)`")
+                        logicalEmptyRelation().when(p -> 
p.getProjects().get(0).toSql().equals("id")
+                                && p.getProjects().get(1).toSql()
+                                .equals("if(age IS NULL, 0, 1) AS `if(age IS 
NULL, 0, 1)`")
                         )
                 );
     }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateLimitTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateLimitTest.java
index 1b28978e76c..bfd8caf3ac1 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateLimitTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateLimitTest.java
@@ -53,6 +53,7 @@ class EliminateLimitTest implements MemoPatternMatchSupported 
{
                 .limit(1, 1).build();
 
         PlanChecker.from(MemoTestUtils.createConnectContext(), limit)
+                .disableNereidsRules("PRUNE_EMPTY_PARTITION")
                 .rewrite()
                 .matches(logicalTopN());
     }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateSortTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateSortTest.java
index 5df92782527..5787229c5ba 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateSortTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateSortTest.java
@@ -63,6 +63,7 @@ class EliminateSortTest extends TestWithFeService implements 
MemoPatternMatchSup
                 .nonMatch(logicalSort());
 
         PlanChecker.from(connectContext)
+                .disableNereidsRules("PRUNE_EMPTY_PARTITION")
                 .analyze("with cte_test as (\n"
                         + "select id, name, age from student\n"
                         + ")\n"
@@ -74,6 +75,7 @@ class EliminateSortTest extends TestWithFeService implements 
MemoPatternMatchSup
                 .matches(logicalSort());
 
         PlanChecker.from(connectContext)
+                .disableNereidsRules("PRUNE_EMPTY_PARTITION")
                 .analyze("select t.age from\n"
                         + "(\n"
                         + "with cte_test as (\n"
@@ -99,6 +101,7 @@ class EliminateSortTest extends TestWithFeService implements 
MemoPatternMatchSup
                 new ArrayList<>(), 
plan.getOutput().stream().map(NamedExpression.class::cast).collect(
                 Collectors.toList()), false, DMLCommandType.NONE, plan);
         PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
+                .disableNereidsRules("PRUNE_EMPTY_PARTITION")
                 .rewrite()
                 .nonMatch(logicalSort())
                 .matches(logicalTopN());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanChecker.java 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanChecker.java
index d0bd735ae92..fdce1c0b9af 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanChecker.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/PlanChecker.java
@@ -162,6 +162,11 @@ public class PlanChecker {
         return this;
     }
 
+    public PlanChecker disableNereidsRules(String rules) {
+        connectContext.getSessionVariable().setDisableNereidsRules(rules);
+        return this;
+    }
+
     public PlanChecker printPlanProcess(String sql) {
         List<PlanProcess> planProcesses = explainPlanProcess(sql);
         for (PlanProcess row : planProcesses) {
diff --git a/regression-test/data/empty_relation/eliminate_empty.out 
b/regression-test/data/empty_relation/eliminate_empty.out
index 1732199a898..ca0d2a4641a 100644
--- a/regression-test/data/empty_relation/eliminate_empty.out
+++ b/regression-test/data/empty_relation/eliminate_empty.out
@@ -72,13 +72,11 @@ PhysicalResultSink
 
 -- !prune_partition1 --
 PhysicalResultSink
---PhysicalProject
-----PhysicalEmptyRelation
+--PhysicalEmptyRelation
 
 -- !prune_partition2 --
 PhysicalResultSink
---PhysicalProject
-----PhysicalEmptyRelation
+--PhysicalEmptyRelation
 
 -- !join_with_empty_child --
 2      8       e       v       3
diff --git a/regression-test/data/load_p0/insert/insert_select_empty_table.out 
b/regression-test/data/load_p0/insert/insert_select_empty_table.out
index 1f1c2e0aa55..fa524f810c5 100644
--- a/regression-test/data/load_p0/insert/insert_select_empty_table.out
+++ b/regression-test/data/load_p0/insert/insert_select_empty_table.out
@@ -9,12 +9,9 @@ PhysicalOlapTableSink
 
 -- !test_shape_join --
 PhysicalOlapTableSink
---PhysicalProject
-----PhysicalEmptyRelation
+--PhysicalEmptyRelation
 
 -- !test_shape_agg_filter_limit --
 PhysicalOlapTableSink
---PhysicalLimit[GLOBAL]
-----PhysicalLimit[LOCAL]
-------PhysicalEmptyRelation
+--PhysicalEmptyRelation
 
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.out
 
b/regression-test/data/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.out
new file mode 100644
index 00000000000..ed7fd6ec910
--- /dev/null
+++ 
b/regression-test/data/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !ds_shape_10 --
+PhysicalResultSink
+--PhysicalEmptyRelation
+
diff --git a/regression-test/suites/empty_relation/eliminate_empty.groovy 
b/regression-test/suites/empty_relation/eliminate_empty.groovy
index 679f1d456a1..2399523ee3d 100644
--- a/regression-test/suites/empty_relation/eliminate_empty.groovy
+++ b/regression-test/suites/empty_relation/eliminate_empty.groovy
@@ -20,9 +20,12 @@
 suite("eliminate_empty") {
     String db = context.config.getDbNameByFile(context.file)
     sql "use ${db}"
-    sql 'set enable_nereids_planner=true'
-    sql 'set enable_fallback_to_original_planner=false'
-    sql 'set forbid_unknown_col_stats=false'
+    multi_sql """
+        SET enable_nereids_planner=true;
+        SET enable_fallback_to_original_planner=false;
+        set disable_nereids_rules='PRUNE_EMPTY_PARTITION';
+        set forbid_unknown_col_stats=false;
+    """
     qt_onerow_union """
         select * from (select 1, 2 union select 3, 4) T order by 1, 2
     """
diff --git 
a/regression-test/suites/load_p0/insert/insert_select_empty_table.groovy 
b/regression-test/suites/load_p0/insert/insert_select_empty_table.groovy
index 8c1956cc506..1567e8eea3e 100644
--- a/regression-test/suites/load_p0/insert/insert_select_empty_table.groovy
+++ b/regression-test/suites/load_p0/insert/insert_select_empty_table.groovy
@@ -16,25 +16,22 @@
 // under the License.
 
 suite("insert_select_empty_table") {
-    sql "SET enable_nereids_planner=true"
-    sql "SET enable_fallback_to_original_planner=false"
-    sql """
-         DROP TABLE IF EXISTS insert_select_empty_table1
-        """
+    multi_sql """
+    SET enable_nereids_planner=true;
+    SET enable_fallback_to_original_planner=false;
 
-    sql """
-        create table insert_select_empty_table1(pk int, a int, b int) 
distributed by hash(pk) buckets 10
-        properties('replication_num' = '1'); 
-        """
-    sql """
-         DROP TABLE IF EXISTS insert_select_empty_table2
-        """
+    DROP TABLE IF EXISTS insert_select_empty_table1;
 
-    sql """
-        create table insert_select_empty_table2(pk int, a int, b int) 
distributed by hash(pk) buckets 10
-        properties('replication_num' = '1'); 
-        """
-    sql "insert into insert_select_empty_table1 select * from 
insert_select_empty_table2;"
+    create table insert_select_empty_table1(pk int, a int, b int) distributed 
by hash(pk) buckets 10
+    properties('replication_num' = '1'); 
+
+    DROP TABLE IF EXISTS insert_select_empty_table2;
+
+    create table insert_select_empty_table2(pk int, a int, b int) distributed 
by hash(pk) buckets 10
+    properties('replication_num' = '1'); 
+    
+    insert into insert_select_empty_table1 select * from 
insert_select_empty_table2;
+    """
     qt_test_shape "explain shape plan insert into insert_select_empty_table1 
select * from insert_select_empty_table2;"
 
     sql """insert into insert_select_empty_table1 select * from 
insert_select_empty_table2 
diff --git a/regression-test/suites/nereids_p0/union/test_union.groovy 
b/regression-test/suites/nereids_p0/union/test_union.groovy
index 81502fc1b43..5e9a9e71bf3 100644
--- a/regression-test/suites/nereids_p0/union/test_union.groovy
+++ b/regression-test/suites/nereids_p0/union/test_union.groovy
@@ -16,8 +16,11 @@
 // under the License.
 
 suite("test_union") {
-    sql "SET enable_nereids_planner=true"
-    sql "SET enable_fallback_to_original_planner=false"
+    multi_sql """
+        SET enable_nereids_planner=true;
+        SET enable_fallback_to_original_planner=false;
+        set disable_nereids_rules='PRUNE_EMPTY_PARTITION';
+    """
     def db = "nereids_test_query_db"
     sql "use ${db}"
 
diff --git 
a/regression-test/suites/nereids_syntax_p0/eliminate_nullaware_anti_join.groovy 
b/regression-test/suites/nereids_syntax_p0/eliminate_nullaware_anti_join.groovy
index e6c9d2f29c3..fe9c81a2911 100644
--- 
a/regression-test/suites/nereids_syntax_p0/eliminate_nullaware_anti_join.groovy
+++ 
b/regression-test/suites/nereids_syntax_p0/eliminate_nullaware_anti_join.groovy
@@ -16,8 +16,11 @@
 // under the License.
 
 suite("eliminate_nullaware_anti_join") {
-    sql "SET enable_nereids_planner=true"
-    sql "SET enable_fallback_to_original_planner=false"
+    multi_sql """
+    SET enable_nereids_planner=true;
+    SET enable_fallback_to_original_planner=false;
+    set disable_nereids_rules='PRUNE_EMPTY_PARTITION';
+    """
 
     sql """drop table if exists eliminate_nullaware_anti_join_A;"""
     sql """drop table if exists eliminate_nullaware_anti_join_B;"""
diff --git 
a/regression-test/suites/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.groovy
 
b/regression-test/suites/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.groovy
new file mode 100644
index 00000000000..e9f4418d59c
--- /dev/null
+++ 
b/regression-test/suites/nereids_tpcds_shape_sf1000_p0/eliminate_empty/query10_empty.groovy
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+suite("query10") {
+    String db = context.config.getDbNameByFile(new File(context.file.parent))
+    sql "use ${db}"
+    sql 'set enable_nereids_planner=true'
+    sql 'set enable_fallback_to_original_planner=false'
+    sql 'set exec_mem_limit=21G'
+    sql 'set be_number_for_test=3'
+    sql 'set parallel_fragment_exec_instance_num=8; '
+    sql 'set parallel_pipeline_task_num=8; '
+    sql 'set forbid_unknown_col_stats=true'
+    sql 'set enable_nereids_timeout = false'
+    sql 'set enable_runtime_filter_prune=false'
+    sql 'set runtime_filter_type=8'
+    sql 'set dump_nereids_memo=false'
+
+    def ds = """select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Fairfield County','Campbell County','Washtenaw 
County','Escambia County','Cleburne County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2001 and
+                d_moy between 3 and 3+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2001 and
+                  d_moy between 3 ANd 3+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2001 and
+                  d_moy between 3 and 3+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100"""
+    qt_ds_shape_10 '''
+    explain shape plan
+    select  
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3,
+  cd_dep_count,
+  count(*) cnt4,
+  cd_dep_employed_count,
+  count(*) cnt5,
+  cd_dep_college_count,
+  count(*) cnt6
+ from
+  customer c,customer_address ca,customer_demographics
+ where
+  c.c_current_addr_sk = ca.ca_address_sk and
+  ca_county in ('Fairfield County','Campbell County','Washtenaw 
County','Escambia County','Cleburne County') and
+  cd_demo_sk = c.c_current_cdemo_sk and 
+  exists (select *
+          from store_sales,date_dim
+          where c.c_customer_sk = ss_customer_sk and
+                ss_sold_date_sk = d_date_sk and
+                d_year = 2001 and
+                d_moy between 3 and 3+3) and
+   (exists (select *
+            from web_sales,date_dim
+            where c.c_customer_sk = ws_bill_customer_sk and
+                  ws_sold_date_sk = d_date_sk and
+                  d_year = 2001 and
+                  d_moy between 3 ANd 3+3) or 
+    exists (select * 
+            from catalog_sales,date_dim
+            where c.c_customer_sk = cs_ship_customer_sk and
+                  cs_sold_date_sk = d_date_sk and
+                  d_year = 2001 and
+                  d_moy between 3 and 3+3))
+ group by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+ order by cd_gender,
+          cd_marital_status,
+          cd_education_status,
+          cd_purchase_estimate,
+          cd_credit_rating,
+          cd_dep_count,
+          cd_dep_employed_count,
+          cd_dep_college_count
+limit 100
+    '''
+}


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

Reply via email to