[enhancement](Nereids): rearrange Limit optimization rules (#26378)
This commit is contained in:
@ -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())
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user