924060929 commented on code in PR #11209:
URL: https://github.com/apache/doris/pull/11209#discussion_r936220676


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java:
##########
@@ -405,6 +408,34 @@ public PlanFragment 
visitPhysicalFilter(PhysicalFilter<Plan> filter, PlanTransla
         return inputFragment;
     }
 
+    @Override
+    public PlanFragment visitPhysicalLimit(PhysicalLimit<Plan> physicalLimit, 
PlanTranslatorContext context) {
+        PlanFragment inputFragment = physicalLimit.child(0).accept(this, 
context);
+        PlanNode child = inputFragment.getPlanRoot();
+        if (child instanceof OlapScanNode) {
+            child.setLimit(physicalLimit.getLimit() + 
physicalLimit.getOffset());
+            return inputFragment;
+        }
+
+        if (child instanceof SortNode) {
+            ((SortNode) child).setOffset(physicalLimit.getOffset());
+            child.setLimit(physicalLimit.getLimit());
+            inputFragment.getChildren().forEach(fragment -> {
+                PlanNode root = fragment.getPlanRoot();
+                if (root instanceof SortNode) {
+                    root.setLimit(physicalLimit.getLimit() + 
physicalLimit.getOffset());
+                }
+            });
+            return inputFragment;
+        }
+
+        if (child instanceof AggregationNode) {

Review Comment:
   I think so, too.
   The sort node + limit = TopN. other plan + limit can simple setLimit.



-- 
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