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


##########
fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java:
##########
@@ -282,6 +282,8 @@ private PlanNode createQueryPlan(QueryStmt stmt, Analyzer 
analyzer, long default
             }
         }
 
+        long sqlSelectLimit = 
analyzer.getContext().getSessionVariable().sqlSelectLimit;

Review Comment:
   createQueryPlan is called recursively, should make sqlSelectLimit as a 
parameter of this function just like defaultOrderByLimit



##########
fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java:
##########
@@ -295,7 +297,8 @@ private PlanNode createQueryPlan(QueryStmt stmt, Analyzer 
analyzer, long default
             ((SortNode) root).setDefaultLimit(limit == -1);
             ((SortNode) root).setOffset(stmt.getOffset());
             if (useTopN) {
-                root.setLimit(limit != -1 ? limit : newDefaultOrderByLimit);
+                // if limit != -1, it means limit clause exists, we get the 
minimum.
+                root.setLimit(limit != -1 ? limit : 
Math.min(newDefaultOrderByLimit, sqlSelectLimit));

Review Comment:
   sqlSelectLimit could small than 0, in this case, sqlSelectLimit should not 
be set to limit



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