morrySnow commented on code in PR #17355:
URL: https://github.com/apache/doris/pull/17355#discussion_r1126274674


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/logical/PushdownLimit.java:
##########
@@ -67,65 +74,45 @@ public List<Rule> buildRules() {
                             LogicalUnion union = limit.child();
                             ImmutableList<Plan> newUnionChildren = 
union.children()
                                     .stream()
-                                    .map(child -> addLimit(limit, child))
+                                    .map(child -> limit.withChildren(child))
                                     .collect(ImmutableList.toImmutableList());
+                            if (union.children().equals(newUnionChildren)) {
+                                return null;
+                            }
                             return 
limit.withChildren(union.withChildren(newUnionChildren));
                         })
-                        .toRule(RuleType.PUSH_LIMIT_THROUGH_UNION)
+                        .toRule(RuleType.PUSH_LIMIT_THROUGH_UNION),
+                logicalLimit(logicalOneRowRelation())
+                        .then(limit -> limit.getLimit() > 0
+                                ? limit.child() : new 
LogicalEmptyRelation(limit.child().getOutput()))
+                        .toRule(RuleType.PUSH_LIMIT_THROUGH_ONE_ROW_RELATION),
+                logicalLimit(logicalEmptyRelation())
+                        .then(UnaryNode::child)
+                        .toRule(RuleType.PUSH_LIMIT_THROUGH_EMPTY_RELATION),

Review Comment:
   we have a file named EliminateLimit



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to