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

jakevin 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 074323f112f [enhancement](Nereids): rearrange Limit optimization rules 
(#26378)
074323f112f is described below

commit 074323f112f28054f77ab9a84db9a56d3c0b9d06
Author: jakevin <jakevin...@gmail.com>
AuthorDate: Fri Nov 3 17:13:44 2023 +0800

    [enhancement](Nereids): rearrange Limit optimization rules (#26378)
---
 .../doris/nereids/jobs/executor/Rewriter.java      | 32 ++++++++++------------
 1 file changed, 14 insertions(+), 18 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 9e450c322c8..7ce4ef267ad 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
@@ -279,19 +279,19 @@ public class Rewriter extends AbstractBatchJobExecutor {
             // ),
 
             topic("Limit optimization",
+                    // 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
+                    topDown(new LimitSortToTopN()),
+                    topDown(new SplitLimit()),
                     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 LimitSortToTopN(),
-                            new SplitLimit(),
                             new PushdownLimit(),
                             new PushdownTopNThroughJoin(),
                             new PushdownLimitDistinctThroughJoin(),
-                            new PushdownTopNThroughWindow(),
-                            new CreatePartitionTopNFromWindow()
+                            new PushdownTopNThroughWindow()
                     ),
+                    topDown(new CreatePartitionTopNFromWindow()),
                     topDown(
                             new PullUpProjectUnderTopN(),
                             new PullUpProjectUnderLimit()
@@ -323,16 +323,16 @@ public class Rewriter extends AbstractBatchJobExecutor {
             topic("topn optimize",
                     topDown(new DeferMaterializeTopNResult())
             ),
+            topic("eliminate",
+                    // SORT_PRUNING should be applied after mergeLimit
+                    custom(RuleType.ELIMINATE_SORT, EliminateSort::new),
+                    bottomUp(new EliminateEmptyRelation())
+            ),
             // this rule batch must keep at the end of rewrite to do some plan 
check
             topic("Final rewrite and check",
                     custom(RuleType.CHECK_DATA_TYPES, CheckDataTypes::new),
                     custom(RuleType.ENSURE_PROJECT_ON_TOP_JOIN, 
EnsureProjectOnTopJoin::new),
-                    topDown(
-                            new PushdownFilterThroughProject(),
-                            new MergeProjects()
-                    ),
-                    // SORT_PRUNING should be applied after mergeLimit
-                    custom(RuleType.ELIMINATE_SORT, EliminateSort::new),
+                    topDown(new PushdownFilterThroughProject(), new 
MergeProjects()),
                     custom(RuleType.ADJUST_CONJUNCTS_RETURN_TYPE, 
AdjustConjunctsReturnType::new),
                     bottomUp(
                             new 
ExpressionRewrite(CheckLegalityAfterRewrite.INSTANCE),
@@ -346,10 +346,6 @@ public class Rewriter extends AbstractBatchJobExecutor {
                             new CollectFilterAboveConsumer(),
                             new CollectProjectAboveConsumer()
                     )
-            ),
-
-            topic("eliminate empty relation",
-                    bottomUp(new EliminateEmptyRelation())
             )
     );
 


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

Reply via email to