This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f5f2e84e31 [refactor](planner) remove the limit return rows of order 
by (#12478)
f5f2e84e31 is described below

commit f5f2e84e31e3331dc75ca3dd98e217b1c10ef20e
Author: FreeOnePlus <54164178+freeonep...@users.noreply.github.com>
AuthorDate: Sat Nov 19 12:45:44 2022 +0800

    [refactor](planner) remove the limit return rows of order by (#12478)
    
    Originally, Order By Limit returned a maximum of 65535 rows of data by 
default during the query,
    but now many businesses do not apply this limit.
    It is necessary to add larger data after the query statement to complete 
the full data query,
    which is extremely inconvenient, so adjustments have been made.
    
    At the same time, I added the variable DEFAULT_ORDER_BY_LIMIT to the 
SessionVariable,
    the default value is -1, if the user does not use the LIMIT keyword or the 
LIMIT value is a negative integer,
    the default query return value is Long.MAX_VALUE. If the corresponding 
maximum query value is set,
    the number of data items is returned according to the maximum query value 
or the value followed by the
    LIMIT keyword.
---
 docs/en/docs/advanced/variables.md                                 | 6 +++++-
 docs/zh-CN/docs/advanced/variables.md                              | 4 ++++
 .../src/main/java/org/apache/doris/planner/SingleNodePlanner.java  | 7 ++++++-
 fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java  | 7 +++++++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/docs/en/docs/advanced/variables.md 
b/docs/en/docs/advanced/variables.md
index 806068fc3d..b61a175c87 100644
--- a/docs/en/docs/advanced/variables.md
+++ b/docs/en/docs/advanced/variables.md
@@ -176,6 +176,10 @@ Note that the comment must start with /*+ and can only 
follow the SELECT.
 
     Used for compatibility with MySQL clients. No practical effect.
 
+* `default_order_by_limit`
+
+  Used to control the default number of items returned after OrderBy. The 
default value is -1, and the maximum number of records after the query is 
returned by default, and the upper limit is the MAX_VALUE of the long data type.
+
 * `delete_without_partition`
 
     When set to true. When using the delete command to delete partition table 
data, no partition is required. The delete operation will be automatically 
applied to all partitions.
@@ -548,4 +552,4 @@ Translated with www.DeepL.com/Translator (free version)
 
 * `validate_password_policy`
 
-       Password strength verification policy. Defaults to `NONE` or `0`, i.e. 
no verification. Can be set to `STRONG` or `2`. When set to `STRONG` or `2`, 
when setting a password via the `ALTER USER` or `SET PASSWORD` commands, the 
password must contain any of "uppercase letters", "lowercase letters", 
"numbers" and "special characters". 3 items, and the length must be greater 
than or equal to 8. Special characters include: `~!@#$%^&*()_+|<>,.?/:;'[]{}"`.
\ No newline at end of file
+       Password strength verification policy. Defaults to `NONE` or `0`, i.e. 
no verification. Can be set to `STRONG` or `2`. When set to `STRONG` or `2`, 
when setting a password via the `ALTER USER` or `SET PASSWORD` commands, the 
password must contain any of "uppercase letters", "lowercase letters", 
"numbers" and "special characters". 3 items, and the length must be greater 
than or equal to 8. Special characters include: `~!@#$%^&*()_+|<>,.?/:;'[]{}"`.
diff --git a/docs/zh-CN/docs/advanced/variables.md 
b/docs/zh-CN/docs/advanced/variables.md
index 80e1b6e4fe..39cf63610e 100644
--- a/docs/zh-CN/docs/advanced/variables.md
+++ b/docs/zh-CN/docs/advanced/variables.md
@@ -174,6 +174,10 @@ SELECT /*+ SET_VAR(query_timeout = 1, 
enable_partition_cache=true) */ sleep(3);
 
   用于兼容 MySQL 客户端。无实际作用。
 
+- `default_order_by_limit`
+
+  用于控制 OrderBy 以后返回的默认条数。默认值为 -1,默认返回查询后的最大条数,上限为 long 数据类型的 MAX_VALUE 值。
+
 - `delete_without_partition`
 
   设置为 true 时。当使用 delete 命令删除分区表数据时,可以不指定分区。delete 操作将会自动应用到所有分区。
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
index 02688673f8..b1234cceec 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java
@@ -236,8 +236,13 @@ public class SingleNodePlanner {
     private PlanNode createQueryPlan(QueryStmt stmt, Analyzer analyzer, long 
defaultOrderByLimit)
             throws UserException {
         long newDefaultOrderByLimit = defaultOrderByLimit;
+        long defaultLimit = 
analyzer.getContext().getSessionVariable().defaultOrderByLimit;
         if (newDefaultOrderByLimit == -1) {
-            newDefaultOrderByLimit = 65535;
+            if (defaultLimit <= -1) {
+                newDefaultOrderByLimit = Long.MAX_VALUE;
+            } else {
+                newDefaultOrderByLimit = defaultLimit;
+            }
         }
         PlanNode root;
         if (stmt instanceof SelectStmt) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index e28e454512..95fb7f8a02 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -203,6 +203,8 @@ public class SessionVariable implements Serializable, 
Writable {
 
     static final String SESSION_CONTEXT = "session_context";
 
+    public static final String DEFAULT_ORDER_BY_LIMIT = 
"default_order_by_limit";
+
     public static final String ENABLE_SINGLE_REPLICA_INSERT = 
"enable_single_replica_insert";
 
     public static final String ENABLE_FUNCTION_PUSHDOWN = 
"enable_function_pushdown";
@@ -244,6 +246,11 @@ public class SessionVariable implements Serializable, 
Writable {
     @VariableMgr.VarAttr(name = ENABLE_EXCHANGE_NODE_PARALLEL_MERGE)
     public boolean enableExchangeNodeParallelMerge = false;
 
+    // By default, the number of Limit items after OrderBy is changed from 
65535 items
+    // before v1.2.0 (not included), to return all items by default
+    @VariableMgr.VarAttr(name = DEFAULT_ORDER_BY_LIMIT)
+    public long defaultOrderByLimit = -1;
+
     // query timeout in second.
     @VariableMgr.VarAttr(name = QUERY_TIMEOUT)
     public int queryTimeoutS = 300;


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

Reply via email to