You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/06/18 13:05:09 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #3806: Add a session variable allow remove order by for subquery in set opertion clause

morningman commented on a change in pull request #3806:
URL: https://github.com/apache/incubator-doris/pull/3806#discussion_r442209934



##########
File path: fe/src/main/java/org/apache/doris/analysis/QueryStmt.java
##########
@@ -285,27 +285,29 @@ protected void createSortInfo(Analyzer analyzer) throws AnalysisException {
         }
 
         sortInfo = new SortInfo(orderingExprs, isAscOrder, nullsFirstParams);
-        // order by w/o limit and offset in inline views, union operands and insert statements
+        // order by w/o limit and offset in inline views, set operands and insert statements
         // are ignored.
-        // TODO chenhao, open this when we don't limit rows subquery returns by SortNode.
-        /*if (!hasLimit() && !hasOffset() && !analyzer.isRootAnalyzer()) {
-         *   evaluateOrderBy = false;
-         *   // Return a warning that the order by was ignored.
-         *   StringBuilder strBuilder = new StringBuilder();
-         *   strBuilder.append("Ignoring ORDER BY clause without LIMIT or OFFSET: ");
-         *   strBuilder.append("ORDER BY ");
-         *   strBuilder.append(orderByElements.get(0).toSql());
-         *   for (int i = 1; i < orderByElements.size(); ++i) {
-         *       strBuilder.append(", ").append(orderByElements.get(i).toSql());
-         *   }
-         *   strBuilder.append(".\nAn ORDER BY appearing in a view, subquery, union operand, ");
-         *   strBuilder.append("or an insert/ctas statement has no effect on the query result ");
-         *   strBuilder.append("unless a LIMIT and/or OFFSET is used in conjunction ");
-         *   strBuilder.append("with the ORDER BY.");
-         * } else {
-         */
-        evaluateOrderBy = true;
-        //}
+        boolean allowIgnore = false;
+        if (ConnectContext.get() != null && ConnectContext.get().getSessionVariable().isAllowIgnoreOrderBy()) {
+            allowIgnore = true;
+        }
+        if (allowIgnore && !hasLimit() && !hasOffset() && !analyzer.isRootAnalyzer()) {
+            evaluateOrderBy = false;
+            // Return a warning that the order by was ignored.
+            StringBuilder strBuilder = new StringBuilder();
+            strBuilder.append("Ignoring ORDER BY clause without LIMIT or OFFSET: ");
+            strBuilder.append("ORDER BY ");
+            strBuilder.append(orderByElements.get(0).toSql());
+            for (int i = 1; i < orderByElements.size(); ++i) {
+                strBuilder.append(", ").append(orderByElements.get(i).toSql());
+            }
+            strBuilder.append(".\nAn ORDER BY appearing in a view, subquery, union operand, ");
+            strBuilder.append("or an insert/ctas statement has no effect on the query result ");
+            strBuilder.append("unless a LIMIT and/or OFFSET is used in conjunction ");
+            strBuilder.append("with the ORDER BY.");

Review comment:
       This `strBuilder` seems useless.

##########
File path: fe/src/main/java/org/apache/doris/qe/SessionVariable.java
##########
@@ -251,6 +253,9 @@
     private int maxScanKeyNum = -1;
     @VariableMgr.VarAttr(name = MAX_PUSHDOWN_CONDITIONS_PER_COLUMN)
     private int maxPushdownConditionsPerColumn = -1;
+    // TODO(Yangzhengguo) set this default value to true if we support spill data top disk
+    @VariableMgr.VarAttr(name = ALLOW_IGNORE_ORDER_BY)
+    private boolean allowIgnoreOrderBy = false;

Review comment:
       Update the document for this new variables.




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

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