You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "morrySnow (via GitHub)" <gi...@apache.org> on 2023/06/21 08:03:10 UTC

[GitHub] [doris] morrySnow commented on a diff in pull request #21068: [Enhancement](planner)support sql_select_limit for 1.2

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-unsubscribe@doris.apache.org

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


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