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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new c02181a018 [Enhancement](Nereids)fix push down global limit to avoid 
gather. (#21891) (#22876)
c02181a018 is described below

commit c02181a018ea4fa8d1f367b0397eecf5bed583ef
Author: mch_ucchi <[email protected]>
AuthorDate: Fri Aug 11 17:26:28 2023 +0800

    [Enhancement](Nereids)fix push down global limit to avoid gather. (#21891) 
(#22876)
---
 .../doris/nereids/jobs/executor/Rewriter.java      | 18 ++--
 .../doris/nereids/rules/rewrite/MergeLimits.java   |  5 +-
 .../doris/nereids/rules/rewrite/PushdownLimit.java | 38 +--------
 .../nereids/rules/rewrite/ReplaceLimitNode.java    | 72 ++++++++++++++++
 .../doris/nereids/trees/plans/LimitPhase.java      |  4 +
 .../nereids/trees/plans/logical/LogicalLimit.java  |  7 +-
 .../nereids/trees/plans/PlanToStringTest.java      |  2 +-
 .../nereids_tpcds_shape_sf100_p0/shape/query28.out | 95 +++++++++++-----------
 .../sub_query_diff_old_optimize.groovy             |  2 +-
 9 files changed, 148 insertions(+), 95 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
index 59c195a5c9..1bba83c592 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
@@ -84,6 +84,7 @@ import 
org.apache.doris.nereids.rules.rewrite.PushdownFilterThroughWindow;
 import org.apache.doris.nereids.rules.rewrite.PushdownLimit;
 import org.apache.doris.nereids.rules.rewrite.PushdownTopNThroughWindow;
 import org.apache.doris.nereids.rules.rewrite.ReorderJoin;
+import org.apache.doris.nereids.rules.rewrite.ReplaceLimitNode;
 import org.apache.doris.nereids.rules.rewrite.RewriteCteChildren;
 import org.apache.doris.nereids.rules.rewrite.SemiJoinCommute;
 import org.apache.doris.nereids.rules.rewrite.SimplifyAggGroupBy;
@@ -243,8 +244,18 @@ public class Rewriter extends AbstractBatchJobExecutor {
                     topDown(new BuildAggForUnion())
             ),
 
-            topic("Window optimization",
+            // topic("Distinct",
+            //         
costBased(custom(RuleType.PUSH_DOWN_DISTINCT_THROUGH_JOIN, 
PushdownDistinctThroughJoin::new))
+            // ),
+
+            topic("Limit optimization",
                     topDown(
+                            // TODO: the logical plan should not contains any 
phase information,
+                            //       we should refactor like 
AggregateStrategies, e.g. LimitStrategies,
+                            //       generate one PhysicalLimit if current 
distribution is gather or two
+                            //       PhysicalLimits with gather exchange
+                            new ReplaceLimitNode(),
+                            new SplitLimit(),
                             new PushdownLimit(),
                             new PushdownTopNThroughWindow(),
                             new PushdownFilterThroughWindow()
@@ -253,11 +264,6 @@ public class Rewriter extends AbstractBatchJobExecutor {
             // TODO: these rules should be implementation rules, and generate 
alternative physical plans.
             topic("Table/Physical optimization",
                     topDown(
-                            // TODO: the logical plan should not contains any 
phase information,
-                            //       we should refactor like 
AggregateStrategies, e.g. LimitStrategies,
-                            //       generate one PhysicalLimit if current 
distribution is gather or two
-                            //       PhysicalLimits with gather exchange
-                            new SplitLimit(),
                             new PruneOlapScanPartition(),
                             new PruneFileScanPartition(),
                             new PushConjunctsIntoJdbcScan()
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/MergeLimits.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/MergeLimits.java
index 83729f6a2c..0621e70b70 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/MergeLimits.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/MergeLimits.java
@@ -42,14 +42,15 @@ public class MergeLimits extends OneRewriteRuleFactory {
     @Override
     public Rule build() {
         return logicalLimit(logicalLimit())
-                .when(upperLimit -> 
upperLimit.getPhase().equals(upperLimit.child().getPhase()))
+                .when(upperLimit -> 
upperLimit.getPhase().equals(upperLimit.child().getPhase())
+                        || (upperLimit.getPhase().isLocal() && 
upperLimit.child().getPhase().isGlobal()))
                 .then(upperLimit -> {
                     LogicalLimit<? extends Plan> bottomLimit = 
upperLimit.child();
                     return new LogicalLimit<>(
                             Math.min(upperLimit.getLimit(),
                                     Math.max(bottomLimit.getLimit() - 
upperLimit.getOffset(), 0)),
                             bottomLimit.getOffset() + upperLimit.getOffset(),
-                            bottomLimit.getPhase(), bottomLimit.child()
+                            upperLimit.getPhase(), bottomLimit.child()
                     );
                 }).toRule(RuleType.MERGE_LIMITS);
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownLimit.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownLimit.java
index 48e2665121..5964d741fc 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownLimit.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushdownLimit.java
@@ -19,22 +19,16 @@ 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.Plan;
 import org.apache.doris.nereids.trees.plans.algebra.Limit;
 import org.apache.doris.nereids.trees.plans.algebra.SetOperation.Qualifier;
-import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
 import org.apache.doris.nereids.trees.plans.logical.LogicalLimit;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
-import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
-import org.apache.doris.nereids.trees.plans.logical.LogicalTopN;
 import org.apache.doris.nereids.trees.plans.logical.LogicalUnion;
 import org.apache.doris.nereids.trees.plans.logical.LogicalWindow;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
 
 import java.util.List;
 import java.util.Optional;
@@ -43,6 +37,7 @@ import java.util.Optional;
  * Rules to push {@link 
org.apache.doris.nereids.trees.plans.logical.LogicalLimit} down.
  * <p>
  * Limit can't be push down if it has a valid offset info.
+ * splitLimit run before this rule, so the limit match the patterns is local 
limit
  */
 public class PushdownLimit implements RewriteRuleFactory {
 
@@ -104,7 +99,7 @@ public class PushdownLimit implements RewriteRuleFactory {
                             LogicalUnion union = limit.child();
                             ImmutableList<Plan> newUnionChildren = 
union.children()
                                     .stream()
-                                    .map(child -> limit.withChildren(child))
+                                    .map(limit::withChildren)
                                     .collect(ImmutableList.toImmutableList());
                             if (union.children().equals(newUnionChildren)) {
                                 return null;
@@ -112,35 +107,6 @@ public class PushdownLimit implements RewriteRuleFactory {
                             return 
limit.withChildren(union.withChildren(newUnionChildren));
                         })
                         .toRule(RuleType.PUSH_LIMIT_THROUGH_UNION),
-                // limit -> sort ==> topN
-                logicalLimit(logicalSort())
-                        .then(limit -> {
-                            LogicalSort sort = limit.child();
-                            LogicalTopN topN = new 
LogicalTopN(sort.getOrderKeys(),
-                                    limit.getLimit(),
-                                    limit.getOffset(),
-                                    sort.child(0));
-                            return topN;
-                        }).toRule(RuleType.PUSH_LIMIT_INTO_SORT),
-                //limit->proj->sort ==> proj->topN
-                logicalLimit(logicalProject(logicalSort()))
-                        .then(limit -> {
-                            LogicalProject project = limit.child();
-                            LogicalSort sort = limit.child().child();
-                            LogicalTopN topN = new 
LogicalTopN(sort.getOrderKeys(),
-                                    limit.getLimit(),
-                                    limit.getOffset(),
-                                    sort.child(0));
-                            return 
project.withChildren(Lists.newArrayList(topN));
-                        }).toRule(RuleType.PUSH_LIMIT_INTO_SORT),
-                logicalLimit(logicalOneRowRelation())
-                        .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),
                 new MergeLimits().build()
         );
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ReplaceLimitNode.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ReplaceLimitNode.java
new file mode 100644
index 0000000000..9ec2e69b26
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ReplaceLimitNode.java
@@ -0,0 +1,72 @@
+// 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.
+
+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.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalEmptyRelation;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
+import org.apache.doris.nereids.trees.plans.logical.LogicalTopN;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+/**
+ * rule to eliminate limit node by replace to other nodes.
+ */
+public class ReplaceLimitNode implements RewriteRuleFactory {
+    @Override
+    public List<Rule> buildRules() {
+        return ImmutableList.of(
+                // limit -> sort ==> topN
+                logicalLimit(logicalSort())
+                        .then(limit -> {
+                            LogicalSort<Plan> sort = limit.child();
+                            return new LogicalTopN<>(sort.getOrderKeys(),
+                                    limit.getLimit(),
+                                    limit.getOffset(),
+                                    sort.child(0));
+                        }).toRule(RuleType.PUSH_LIMIT_INTO_SORT),
+                //limit->proj->sort ==> proj->topN
+                logicalLimit(logicalProject(logicalSort()))
+                        .then(limit -> {
+                            LogicalProject project = limit.child();
+                            LogicalSort sort = limit.child().child();
+                            LogicalTopN topN = new 
LogicalTopN(sort.getOrderKeys(),
+                                    limit.getLimit(),
+                                    limit.getOffset(),
+                                    sort.child(0));
+                            return 
project.withChildren(Lists.newArrayList(topN));
+                        }).toRule(RuleType.PUSH_LIMIT_INTO_SORT),
+                logicalLimit(logicalOneRowRelation())
+                        .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)
+        );
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/LimitPhase.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/LimitPhase.java
index 705c712ef4..23e65726a4 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/LimitPhase.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/LimitPhase.java
@@ -35,4 +35,8 @@ public enum LimitPhase {
     public boolean isLocal() {
         return this == LOCAL;
     }
+
+    public boolean isGlobal() {
+        return this == GLOBAL;
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java
index 48b89e761d..f03f335f01 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalLimit.java
@@ -86,7 +86,8 @@ public class LogicalLimit<CHILD_TYPE extends Plan> extends 
LogicalUnary<CHILD_TY
     public String toString() {
         return Utils.toSqlString("LogicalLimit",
                 "limit", limit,
-                "offset", offset
+                "offset", offset,
+                "phase", phase
         );
     }
 
@@ -116,6 +117,10 @@ public class LogicalLimit<CHILD_TYPE extends Plan> extends 
LogicalUnary<CHILD_TY
         return ImmutableList.of();
     }
 
+    public LogicalLimit<Plan> withLimitPhase(LimitPhase phase) {
+        return new LogicalLimit<>(limit, offset, phase, child());
+    }
+
     @Override
     public Plan withGroupExpression(Optional<GroupExpression> groupExpression) 
{
         return new LogicalLimit<>(limit, offset, phase, groupExpression, 
Optional.of(getLogicalProperties()), child());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java
index 1e33538cb5..7d9594c73b 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/PlanToStringTest.java
@@ -48,7 +48,7 @@ public class PlanToStringTest {
     public void testLogicalLimit(@Mocked Plan child) {
         LogicalLimit<Plan> plan = new LogicalLimit<>(0, 0, LimitPhase.ORIGIN, 
child);
 
-        Assertions.assertEquals("LogicalLimit ( limit=0, offset=0 )", 
plan.toString());
+        Assertions.assertEquals("LogicalLimit ( limit=0, offset=0, 
phase=ORIGIN )", plan.toString());
     }
 
     @Test
diff --git 
a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query28.out 
b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query28.out
index cf9431b2e0..5de8b9bdd4 100644
--- a/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query28.out
+++ b/regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query28.out
@@ -2,62 +2,61 @@
 -- !ds_shape_28 --
 PhysicalResultSink
 --PhysicalLimit
-----PhysicalLimit
-------PhysicalProject
---------NestedLoopJoin[CROSS_JOIN]
-----------PhysicalLimit
-------------NestedLoopJoin[CROSS_JOIN]
---------------PhysicalLimit
-----------------NestedLoopJoin[CROSS_JOIN]
-------------------PhysicalLimit
---------------------NestedLoopJoin[CROSS_JOIN]
-----------------------PhysicalLimit
-------------------------NestedLoopJoin[CROSS_JOIN]
+----PhysicalProject
+------NestedLoopJoin[CROSS_JOIN]
+--------PhysicalLimit
+----------NestedLoopJoin[CROSS_JOIN]
+------------PhysicalLimit
+--------------NestedLoopJoin[CROSS_JOIN]
+----------------PhysicalLimit
+------------------NestedLoopJoin[CROSS_JOIN]
+--------------------PhysicalLimit
+----------------------NestedLoopJoin[CROSS_JOIN]
+------------------------PhysicalLimit
+--------------------------hashAgg[GLOBAL]
+----------------------------PhysicalDistribute
+------------------------------hashAgg[LOCAL]
+--------------------------------PhysicalProject
+----------------------------------filter((store_sales.ss_quantity <= 
5)((((store_sales.ss_list_price >= 131.00) AND (store_sales.ss_list_price <= 
141.00)) OR ((store_sales.ss_coupon_amt >= 16798.00) AND 
(store_sales.ss_coupon_amt <= 17798.00))) OR ((store_sales.ss_wholesale_cost >= 
25.00) AND (store_sales.ss_wholesale_cost <= 45.00)))(store_sales.ss_quantity 
>= 0))
+------------------------------------PhysicalOlapScan[store_sales]
+------------------------PhysicalDistribute
 --------------------------PhysicalLimit
 ----------------------------hashAgg[GLOBAL]
 ------------------------------PhysicalDistribute
 --------------------------------hashAgg[LOCAL]
 ----------------------------------PhysicalProject
-------------------------------------filter((store_sales.ss_quantity <= 
5)((((store_sales.ss_list_price >= 131.00) AND (store_sales.ss_list_price <= 
141.00)) OR ((store_sales.ss_coupon_amt >= 16798.00) AND 
(store_sales.ss_coupon_amt <= 17798.00))) OR ((store_sales.ss_wholesale_cost >= 
25.00) AND (store_sales.ss_wholesale_cost <= 45.00)))(store_sales.ss_quantity 
>= 0))
+------------------------------------filter((store_sales.ss_quantity <= 
10)((((store_sales.ss_list_price >= 145.00) AND (store_sales.ss_list_price <= 
155.00)) OR ((store_sales.ss_coupon_amt >= 14792.00) AND 
(store_sales.ss_coupon_amt <= 15792.00))) OR ((store_sales.ss_wholesale_cost >= 
46.00) AND (store_sales.ss_wholesale_cost <= 66.00)))(store_sales.ss_quantity 
>= 6))
 --------------------------------------PhysicalOlapScan[store_sales]
+--------------------PhysicalDistribute
+----------------------PhysicalLimit
+------------------------hashAgg[GLOBAL]
 --------------------------PhysicalDistribute
-----------------------------PhysicalLimit
-------------------------------hashAgg[GLOBAL]
---------------------------------PhysicalDistribute
-----------------------------------hashAgg[LOCAL]
-------------------------------------PhysicalProject
---------------------------------------filter((store_sales.ss_quantity <= 
10)((((store_sales.ss_list_price >= 145.00) AND (store_sales.ss_list_price <= 
155.00)) OR ((store_sales.ss_coupon_amt >= 14792.00) AND 
(store_sales.ss_coupon_amt <= 15792.00))) OR ((store_sales.ss_wholesale_cost >= 
46.00) AND (store_sales.ss_wholesale_cost <= 66.00)))(store_sales.ss_quantity 
>= 6))
-----------------------------------------PhysicalOlapScan[store_sales]
+----------------------------hashAgg[LOCAL]
+------------------------------PhysicalProject
+--------------------------------filter(((((store_sales.ss_list_price >= 
1.5E+2) AND (store_sales.ss_list_price <= 1.6E+2)) OR 
((store_sales.ss_coupon_amt >= 6.6E+3) AND (store_sales.ss_coupon_amt <= 
7.6E+3))) OR ((store_sales.ss_wholesale_cost >= 9.00) AND 
(store_sales.ss_wholesale_cost <= 29.00)))(store_sales.ss_quantity >= 
11)(store_sales.ss_quantity <= 15))
+----------------------------------PhysicalOlapScan[store_sales]
+----------------PhysicalDistribute
+------------------PhysicalLimit
+--------------------hashAgg[GLOBAL]
 ----------------------PhysicalDistribute
-------------------------PhysicalLimit
---------------------------hashAgg[GLOBAL]
-----------------------------PhysicalDistribute
-------------------------------hashAgg[LOCAL]
---------------------------------PhysicalProject
-----------------------------------filter(((((store_sales.ss_list_price >= 
1.5E+2) AND (store_sales.ss_list_price <= 1.6E+2)) OR 
((store_sales.ss_coupon_amt >= 6.6E+3) AND (store_sales.ss_coupon_amt <= 
7.6E+3))) OR ((store_sales.ss_wholesale_cost >= 9.00) AND 
(store_sales.ss_wholesale_cost <= 29.00)))(store_sales.ss_quantity >= 
11)(store_sales.ss_quantity <= 15))
-------------------------------------PhysicalOlapScan[store_sales]
+------------------------hashAgg[LOCAL]
+--------------------------PhysicalProject
+----------------------------filter((store_sales.ss_quantity <= 
20)((((store_sales.ss_list_price >= 91.00) AND (store_sales.ss_list_price <= 
101.00)) OR ((store_sales.ss_coupon_amt >= 13493.00) AND 
(store_sales.ss_coupon_amt <= 14493.00))) OR ((store_sales.ss_wholesale_cost >= 
36.00) AND (store_sales.ss_wholesale_cost <= 56.00)))(store_sales.ss_quantity 
>= 16))
+------------------------------PhysicalOlapScan[store_sales]
+------------PhysicalDistribute
+--------------PhysicalLimit
+----------------hashAgg[GLOBAL]
 ------------------PhysicalDistribute
---------------------PhysicalLimit
-----------------------hashAgg[GLOBAL]
-------------------------PhysicalDistribute
---------------------------hashAgg[LOCAL]
-----------------------------PhysicalProject
-------------------------------filter((store_sales.ss_quantity <= 
20)((((store_sales.ss_list_price >= 91.00) AND (store_sales.ss_list_price <= 
101.00)) OR ((store_sales.ss_coupon_amt >= 13493.00) AND 
(store_sales.ss_coupon_amt <= 14493.00))) OR ((store_sales.ss_wholesale_cost >= 
36.00) AND (store_sales.ss_wholesale_cost <= 56.00)))(store_sales.ss_quantity 
>= 16))
---------------------------------PhysicalOlapScan[store_sales]
+--------------------hashAgg[LOCAL]
+----------------------PhysicalProject
+------------------------filter(((((store_sales.ss_list_price >= 0.00) AND 
(store_sales.ss_list_price <= 10.00)) OR ((store_sales.ss_coupon_amt >= 
7629.00) AND (store_sales.ss_coupon_amt <= 8629.00))) OR 
((store_sales.ss_wholesale_cost >= 6.00) AND (store_sales.ss_wholesale_cost <= 
26.00)))(store_sales.ss_quantity <= 25)(store_sales.ss_quantity >= 21))
+--------------------------PhysicalOlapScan[store_sales]
+--------PhysicalDistribute
+----------PhysicalLimit
+------------hashAgg[GLOBAL]
 --------------PhysicalDistribute
-----------------PhysicalLimit
-------------------hashAgg[GLOBAL]
---------------------PhysicalDistribute
-----------------------hashAgg[LOCAL]
-------------------------PhysicalProject
---------------------------filter(((((store_sales.ss_list_price >= 0.00) AND 
(store_sales.ss_list_price <= 10.00)) OR ((store_sales.ss_coupon_amt >= 
7629.00) AND (store_sales.ss_coupon_amt <= 8629.00))) OR 
((store_sales.ss_wholesale_cost >= 6.00) AND (store_sales.ss_wholesale_cost <= 
26.00)))(store_sales.ss_quantity <= 25)(store_sales.ss_quantity >= 21))
-----------------------------PhysicalOlapScan[store_sales]
-----------PhysicalDistribute
-------------PhysicalLimit
---------------hashAgg[GLOBAL]
-----------------PhysicalDistribute
-------------------hashAgg[LOCAL]
---------------------PhysicalProject
-----------------------filter((store_sales.ss_quantity >= 
26)((((store_sales.ss_list_price >= 89.00) AND (store_sales.ss_list_price <= 
99.00)) OR ((store_sales.ss_coupon_amt >= 15257.00) AND 
(store_sales.ss_coupon_amt <= 16257.00))) OR ((store_sales.ss_wholesale_cost >= 
31.00) AND (store_sales.ss_wholesale_cost <= 51.00)))(store_sales.ss_quantity 
<= 30))
-------------------------PhysicalOlapScan[store_sales]
+----------------hashAgg[LOCAL]
+------------------PhysicalProject
+--------------------filter((store_sales.ss_quantity >= 
26)((((store_sales.ss_list_price >= 89.00) AND (store_sales.ss_list_price <= 
99.00)) OR ((store_sales.ss_coupon_amt >= 15257.00) AND 
(store_sales.ss_coupon_amt <= 16257.00))) OR ((store_sales.ss_wholesale_cost >= 
31.00) AND (store_sales.ss_wholesale_cost <= 51.00)))(store_sales.ss_quantity 
<= 30))
+----------------------PhysicalOlapScan[store_sales]
 
diff --git 
a/regression-test/suites/nereids_syntax_p0/sub_query_diff_old_optimize.groovy 
b/regression-test/suites/nereids_syntax_p0/sub_query_diff_old_optimize.groovy
index 76f07ac9c5..6327b6c8aa 100644
--- 
a/regression-test/suites/nereids_syntax_p0/sub_query_diff_old_optimize.groovy
+++ 
b/regression-test/suites/nereids_syntax_p0/sub_query_diff_old_optimize.groovy
@@ -159,7 +159,7 @@ suite ("sub_query_diff_old_optimize") {
         sql """
             select * from sub_query_diff_old_optimize_subquery1 where 
sub_query_diff_old_optimize_subquery1.k1 not in (select 
sub_query_diff_old_optimize_subquery3.k3 from 
sub_query_diff_old_optimize_subquery3 where 
sub_query_diff_old_optimize_subquery3.v2 = 
sub_query_diff_old_optimize_subquery1.k2 limit 1);
         """
-        exception "java.sql.SQLException: errCode = 2, detailMessage = 
Unexpected exception: Unsupported correlated subquery with a LIMIT clause 
LogicalLimit ( limit=1, offset=0 )"
+        exception "java.sql.SQLException: errCode = 2, detailMessage = 
Unexpected exception: Unsupported correlated subquery with a LIMIT clause 
LogicalLimit ( limit=1, offset=0, phase=ORIGIN )"
 
     }
 


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

Reply via email to