You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/08/29 02:13:36 UTC

[doris] branch revert-9745-limit_set_order created (now 66a02d6ec3)

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

morningman pushed a change to branch revert-9745-limit_set_order
in repository https://gitbox.apache.org/repos/asf/doris.git


      at 66a02d6ec3 Revert "[behavior change](planner)change Doris's query organization syntax to standard sql (#9745)"

This branch includes the following new commits:

     new 66a02d6ec3 Revert "[behavior change](planner)change Doris's query organization syntax to standard sql (#9745)"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[doris] 01/01: Revert "[behavior change](planner)change Doris's query organization syntax to standard sql (#9745)"

Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch revert-9745-limit_set_order
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 66a02d6ec3c5e7777b7c03d39efc8e90e9ee5907
Author: Mingyu Chen <mo...@gmail.com>
AuthorDate: Mon Aug 29 10:13:30 2022 +0800

    Revert "[behavior change](planner)change Doris's query organization syntax to standard sql (#9745)"
    
    This reverts commit f19c34432874d199004b7be565aaa020358f4891.
---
 fe/fe-core/src/main/cup/sql_parser.cup             |  99 +++++++-----------
 .../doris/analysis/CreateMaterializedViewStmt.java |  21 ++--
 .../java/org/apache/doris/analysis/QueryStmt.java  |   8 --
 .../java/org/apache/doris/analysis/SelectStmt.java |  19 ++--
 .../apache/doris/analysis/SetOperationStmt.java    |  10 +-
 .../org/apache/doris/analysis/ShowColumnStmt.java  |   2 +-
 .../java/org/apache/doris/analysis/ShowDbStmt.java |   2 +-
 .../apache/doris/analysis/ShowTableStatusStmt.java |   2 +-
 .../org/apache/doris/analysis/ShowTableStmt.java   |   2 +-
 .../apache/doris/analysis/ShowVariablesStmt.java   |   2 +-
 .../org/apache/doris/analysis/StmtRewriter.java    |   9 +-
 .../analysis/CreateMaterializedViewStmtTest.java   |   2 +-
 .../doris/analysis/QueryOrganizationTest.java      | 116 ---------------------
 .../org/apache/doris/analysis/SelectStmtTest.java  |   2 +-
 .../org/apache/doris/catalog/CreateViewTest.java   |   8 +-
 15 files changed, 76 insertions(+), 228 deletions(-)

diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup
index 1dbd7dddcf..491d4db81f 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -1455,9 +1455,9 @@ create_stmt ::=
     {:
         RESULT = new CreateFileStmt(fileName, db, properties);
     :}
-    | KW_CREATE KW_MATERIALIZED KW_VIEW ident:mvName KW_AS query_stmt:queryStmt opt_properties:properties
+    | KW_CREATE KW_MATERIALIZED KW_VIEW ident:mvName KW_AS select_stmt:selectStmt opt_properties:properties
     {:
-        RESULT = new CreateMaterializedViewStmt(mvName, queryStmt, properties);
+        RESULT = new CreateMaterializedViewStmt(mvName, selectStmt, properties);
     :}
     | KW_CREATE KW_MATERIALIZED KW_VIEW ident:mvName build_mv:buildMethod
          opt_mv_refersh_info:refreshInfo
@@ -2903,13 +2903,13 @@ show_param ::=
     {:
         SelectList list = new SelectList();
         list.addItem(new SelectListItem(new IntLiteral((long)0), null));
-        RESULT = new SelectStmt(list, null, null, null, null);
+        RESULT = new SelectStmt(list, null, null, null, null, null, null);
     :}
     | KW_COUNT LPAREN STAR RPAREN KW_ERRORS
     {:
         SelectList list = new SelectList();
         list.addItem(new SelectListItem(new IntLiteral((long)0), null));
-        RESULT = new SelectStmt(list, null, null, null, null);
+        RESULT = new SelectStmt(list, null, null, null, null, null, null);
     :}
     | KW_WARNINGS limit_clause
     {:
@@ -3436,113 +3436,86 @@ with_view_def_list ::=
     :}
     ;
 
+// We must have a non-empty order by or limit for them to bind to the union.
+// We cannot reuse the existing order_by_clause or
+// limit_clause because they would introduce conflicts with EOF,
+// which, unfortunately, cannot be accessed in the parser as a nonterminal
+// making this issue unresolvable.
+// We rely on the left precedence of KW_ORDER, KW_BY, and KW_LIMIT,
+// to resolve the ambiguity with select_stmt in favor of select_stmt
+// (i.e., ORDER BY and LIMIT bind to the select_stmt by default, and not the set operation).
+// There must be at least two set operands for ORDER BY or LIMIT to bind to a set operation,
+// and we manually throw a parse error if we reach this production
+// with only a single operand.
 set_operation_with_order_by_or_limit ::=
     set_operand_list:operands
     KW_LIMIT INTEGER_LITERAL:limit
   {:
-    LimitElement limitElement = new LimitElement(limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, null, limitElement);
+      parser.parseError("limit", SqlParserSymbols.KW_LIMIT);
     }
+    RESULT = new SetOperationStmt(operands, null, new LimitElement(limit.longValue()));
   :}
   |
     set_operand_list:operands
     KW_LIMIT INTEGER_LITERAL:offset COMMA INTEGER_LITERAL:limit
   {:
-    LimitElement limitElement = new LimitElement(offset.longValue(), limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, null, limitElement);
+      parser.parseError("limit", SqlParserSymbols.KW_LIMIT);
     }
+    RESULT = new SetOperationStmt(operands, null, new LimitElement(offset.longValue(), limit.longValue()));
   :}
   |
     set_operand_list:operands
     KW_LIMIT INTEGER_LITERAL:limit KW_OFFSET INTEGER_LITERAL:offset
   {:
-    LimitElement limitElement = new LimitElement(offset.longValue(), limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, null, limitElement);
+      parser.parseError("limit", SqlParserSymbols.KW_LIMIT);
     }
+    RESULT = new SetOperationStmt(operands, null, new LimitElement(offset.longValue(), limit.longValue()));
   :}
   |
     set_operand_list:operands
     KW_ORDER KW_BY order_by_elements:orderByClause
   {:
-    LimitElement limitElement = LimitElement.NO_LIMIT;
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      queryStmt.setOrderByElements(orderByClause);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, orderByClause, limitElement);
+      parser.parseError("order", SqlParserSymbols.KW_ORDER);
     }
+    RESULT = new SetOperationStmt(operands, orderByClause, LimitElement.NO_LIMIT);
   :}
   |
     set_operand_list:operands
     KW_ORDER KW_BY order_by_elements:orderByClause
     KW_LIMIT INTEGER_LITERAL:limit
   {:
-    LimitElement limitElement = new LimitElement(limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      queryStmt.setOrderByElements(orderByClause);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, orderByClause, limitElement);
+      parser.parseError("order", SqlParserSymbols.KW_ORDER);
     }
+    RESULT = new SetOperationStmt(operands, orderByClause, new LimitElement(limit.longValue()));
   :}
   |
     set_operand_list:operands
     KW_ORDER KW_BY order_by_elements:orderByClause
     KW_LIMIT INTEGER_LITERAL:offset COMMA INTEGER_LITERAL:limit
   {:
-    LimitElement limitElement = new LimitElement(offset.longValue(), limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      queryStmt.setOrderByElements(orderByClause);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, orderByClause, limitElement);
+      parser.parseError("order", SqlParserSymbols.KW_ORDER);
     }
+    RESULT = new SetOperationStmt(operands, orderByClause, new LimitElement(offset.longValue(), limit.longValue()));
   :}
   |
     set_operand_list:operands
     KW_ORDER KW_BY order_by_elements:orderByClause
     KW_LIMIT INTEGER_LITERAL:limit KW_OFFSET INTEGER_LITERAL:offset
   {:
-    LimitElement limitElement = new LimitElement(offset.longValue(), limit.longValue());
     if (operands.size() == 1) {
-      SetOperand setOperand = operands.get(0);
-      QueryStmt queryStmt = setOperand.getQueryStmt();
-      queryStmt.setLimitElement(limitElement);
-      queryStmt.setOrderByElements(orderByClause);
-      RESULT = queryStmt;
-    } else {
-      RESULT = new SetOperationStmt(operands, orderByClause, limitElement);
+      parser.parseError("order", SqlParserSymbols.KW_ORDER);
     }
+    RESULT = new SetOperationStmt(operands, orderByClause, new LimitElement(offset.longValue(), limit.longValue()));
   :}
   ;
 
+
 set_operand ::=
   select_stmt:select
   {:
@@ -4061,19 +4034,23 @@ set_expr_or_default ::=
 
 select_stmt ::=
   select_clause:selectList
-  {: RESULT = new SelectStmt(selectList, null, null, null, null); :}
+    limit_clause:limitClause
+  {: RESULT = new SelectStmt(selectList, null, null, null, null, null, limitClause); :}
   | select_clause:selectList
     from_clause:fromClause
     where_clause:wherePredicate
     group_by_clause:groupByClause
     having_clause:havingPredicate
+    order_by_clause:orderByClause
+    limit_clause:limitClause
   {:
     RESULT = new SelectStmt(selectList, fromClause, wherePredicate,
-                            groupByClause, havingPredicate);
+                            groupByClause, havingPredicate, orderByClause,
+                            limitClause);
   :}
-  | value_clause:valueClause
+  | value_clause:valueClause order_by_clause:orderByClause limit_clause:limitClause
   {:
-      RESULT = new SelectStmt(valueClause);
+      RESULT = new SelectStmt(valueClause, orderByClause, limitClause);
   :}
   ;
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
index 02319c91dd..28926ac73e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
@@ -75,7 +75,6 @@ public class CreateMaterializedViewStmt extends DdlStmt {
     }
 
     private String mvName;
-    private QueryStmt queryStmt;
     private SelectStmt selectStmt;
     private Map<String, String> properties;
 
@@ -96,16 +95,9 @@ public class CreateMaterializedViewStmt extends DdlStmt {
     // only in Rollup or MaterializedIndexMeta is true
     private boolean isReplay = false;
 
-    /**
-     * Constructor.
-     *
-     * @param mvName materialized view name
-     * @param queryStmt query stmt for construct materialized view. Must be SelectStmt
-     * @param properties properties for materialized view
-     */
-    public CreateMaterializedViewStmt(String mvName, QueryStmt queryStmt, Map<String, String> properties) {
+    public CreateMaterializedViewStmt(String mvName, SelectStmt selectStmt, Map<String, String> properties) {
         this.mvName = mvName;
-        this.queryStmt = queryStmt;
+        this.selectStmt = selectStmt;
         this.properties = properties;
     }
 
@@ -117,6 +109,10 @@ public class CreateMaterializedViewStmt extends DdlStmt {
         return mvName;
     }
 
+    public SelectStmt getSelectStmt() {
+        return selectStmt;
+    }
+
     public List<MVColumnItem> getMVColumnItemList() {
         return mvColumnItemList;
     }
@@ -141,11 +137,6 @@ public class CreateMaterializedViewStmt extends DdlStmt {
     public void analyze(Analyzer analyzer) throws UserException {
         super.analyze(analyzer);
         FeNameFormat.checkTableName(mvName);
-        if (!(queryStmt instanceof SelectStmt)) {
-            throw new AnalysisException("Set operation is not supported in add materialized view clause, statement.");
-        }
-        selectStmt = (SelectStmt) queryStmt;
-
         // TODO(ml): The mv name in from clause should pass the analyze without error.
         selectStmt.forbiddenMVRewrite();
         selectStmt.analyze(analyzer);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
index 19f75a7bb7..03ee4048f9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
@@ -568,10 +568,6 @@ public abstract class QueryStmt extends StatementBase implements Queriable {
 
     abstract List<TupleId> collectTupleIds();
 
-    public void setOrderByElements(ArrayList<OrderByElement> orderByElements) {
-        this.orderByElements = orderByElements;
-    }
-
     public ArrayList<OrderByElement> getOrderByElements() {
         return orderByElements;
     }
@@ -618,10 +614,6 @@ public abstract class QueryStmt extends StatementBase implements Queriable {
         limitElement = new LimitElement(newLimit);
     }
 
-    public void setLimitElement(LimitElement limitElement) {
-        this.limitElement = limitElement;
-    }
-
     public void removeLimitElement() {
         limitElement = LimitElement.NO_LIMIT;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 98b7a7599c..8e4ae4eaa2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -118,26 +118,23 @@ public class SelectStmt extends QueryStmt {
     // Members that need to be reset to origin
     private SelectList originSelectList;
 
-    /**
-     * Constructor for SelectStmt. This is used for the following cases.
-     * 1. SELECT * FROM VALUES(a1, b1, c1), (a2, b2, c2);
-     *
-     * @param valueList value list
-     */
-    public SelectStmt(ValueList valueList) {
-        super(null, LimitElement.NO_LIMIT);
+    public SelectStmt(ValueList valueList, ArrayList<OrderByElement> orderByElement, LimitElement limitElement) {
+        super(orderByElement, limitElement);
         this.valueList = valueList;
         this.selectList = new SelectList();
         this.fromClause = new FromClause();
         this.colLabels = Lists.newArrayList();
     }
 
-    SelectStmt(SelectList selectList,
+    SelectStmt(
+            SelectList selectList,
             FromClause fromClause,
             Expr wherePredicate,
             GroupByClause groupByClause,
-            Expr havingPredicate) {
-        super(null, LimitElement.NO_LIMIT);
+            Expr havingPredicate,
+            ArrayList<OrderByElement> orderByElements,
+            LimitElement limitElement) {
+        super(orderByElements, limitElement);
         this.selectList = selectList;
         this.originSelectList = selectList.clone();
         if (fromClause == null) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
index cfb4095e48..7fdd67c8d6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
@@ -681,12 +681,18 @@ public class SetOperationStmt extends QueryStmt {
             strBuilder.append(" ");
         }
         Preconditions.checkState(operands.size() > 0);
-        strBuilder.append("(").append(operands.get(0).getQueryStmt().toSql()).append(")");
+        strBuilder.append(operands.get(0).getQueryStmt().toSql());
         for (int i = 1; i < operands.size() - 1; ++i) {
             strBuilder.append(" "
                     + operands.get(i).getOperation().toString() + " "
                     + ((operands.get(i).getQualifier() == Qualifier.ALL) ? "ALL " : ""));
-            strBuilder.append("(").append(operands.get(i).getQueryStmt().toSql()).append(")");
+            if (operands.get(i).getQueryStmt() instanceof SetOperationStmt) {
+                strBuilder.append("(");
+            }
+            strBuilder.append(operands.get(i).getQueryStmt().toSql());
+            if (operands.get(i).getQueryStmt() instanceof SetOperationStmt) {
+                strBuilder.append(")");
+            }
         }
         // Determine whether we need parenthesis around the last Set operand.
         SetOperand lastOperand = operands.get(operands.size() - 1);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowColumnStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowColumnStmt.java
index 364d7ddc7d..f50e698cda 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowColumnStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowColumnStmt.java
@@ -163,7 +163,7 @@ public class ShowColumnStmt extends ShowStmt {
         where = where.substitute(aliasMap);
         selectStmt = new SelectStmt(selectList,
                 new FromClause(Lists.newArrayList(new TableRef(TABLE_NAME, null))),
-                where, null, null);
+                where, null, null, null, LimitElement.NO_LIMIT);
         analyzer.setSchemaInfo(tableName.getDb(), tableName.getTbl(), null);
 
         return selectStmt;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDbStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDbStmt.java
index 282a7200c0..29d65c9feb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDbStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDbStmt.java
@@ -87,7 +87,7 @@ public class ShowDbStmt extends ShowStmt {
         where = where.substitute(aliasMap);
         selectStmt = new SelectStmt(selectList,
                 new FromClause(Lists.newArrayList(new TableRef(TABLE_NAME, null))),
-                where, null, null);
+                where, null, null, null, LimitElement.NO_LIMIT);
 
         return selectStmt;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStatusStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStatusStmt.java
index 9ed5c4bfdc..956735b3c8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStatusStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStatusStmt.java
@@ -182,7 +182,7 @@ public class ShowTableStatusStmt extends ShowStmt {
         where = where.substitute(aliasMap);
         selectStmt = new SelectStmt(selectList,
                 new FromClause(Lists.newArrayList(new TableRef(TABLE_NAME, null))),
-                where, null, null);
+                where, null, null, null, LimitElement.NO_LIMIT);
         analyzer.setSchemaInfo(db, null, null);
 
         return selectStmt;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStmt.java
index fe5b7bb6a0..dc5acfd09d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTableStmt.java
@@ -112,7 +112,7 @@ public class ShowTableStmt extends ShowStmt {
         where = where.substitute(aliasMap);
         selectStmt = new SelectStmt(selectList,
                 new FromClause(Lists.newArrayList(new TableRef(TABLE_NAME, null))),
-                where, null, null);
+                where, null, null, null, LimitElement.NO_LIMIT);
 
         analyzer.setSchemaInfo(ClusterNamespace.getNameFromFullName(db), null, null);
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowVariablesStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowVariablesStmt.java
index 049168dbb1..bce1499ef9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowVariablesStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowVariablesStmt.java
@@ -101,7 +101,7 @@ public class ShowVariablesStmt extends ShowStmt {
         where = where.substitute(aliasMap);
         selectStmt = new SelectStmt(selectList,
                 new FromClause(Lists.newArrayList(new TableRef(tableName, null))),
-                where, null, null);
+                where, null, null, null, LimitElement.NO_LIMIT);
         LOG.debug("select stmt is {}", selectStmt.toSql());
 
         // DB: type
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
index d68b60e4a3..5cdb4bba36 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
@@ -273,9 +273,8 @@ public class StmtRewriter {
         List<TableRef> newTableRefList = Lists.newArrayList();
         newTableRefList.add(inlineViewRef);
         FromClause newFromClause = new FromClause(newTableRefList);
-        SelectStmt result = new SelectStmt(newSelectList, newFromClause, newWherePredicate, null, null);
-        result.setOrderByElements(newOrderByElements);
-        result.setLimitElement(limitElement);
+        SelectStmt result = new SelectStmt(newSelectList, newFromClause, newWherePredicate, null, null,
+                newOrderByElements, limitElement);
         result.setTableAliasGenerator(tableAliasGenerator);
         try {
             result.analyze(analyzer);
@@ -1206,7 +1205,9 @@ public class StmtRewriter {
                     new FromClause(Lists.newArrayList(tableRef)),
                     matchPolicy.getWherePredicate(),
                     null,
-                    null);
+                    null,
+                    null,
+                    LimitElement.NO_LIMIT);
             selectStmt.fromClause.set(i, new InlineViewRef(tableRef.getAliasAsName().getTbl(), stmt));
             selectStmt.analyze(analyzer);
             reAnalyze = true;
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
index da183db58d..6513170ba2 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
@@ -66,7 +66,7 @@ public class CreateMaterializedViewStmtTest {
         SelectListItem selectListItem = new SelectListItem(arithmeticExpr, null);
         selectList.addItem(selectListItem);
         FromClause fromClause = new FromClause();
-        SelectStmt selectStmt = new SelectStmt(selectList, fromClause, null, null, null);
+        SelectStmt selectStmt = new SelectStmt(selectList, fromClause, null, null, null, null, LimitElement.NO_LIMIT);
 
         new Expectations() {
             {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryOrganizationTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryOrganizationTest.java
deleted file mode 100644
index 83b95ba35a..0000000000
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryOrganizationTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package org.apache.doris.analysis;
-
-import org.apache.doris.common.UserException;
-import org.apache.doris.common.util.SqlParserUtils;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-import java.io.StringReader;
-
-public class QueryOrganizationTest {
-    @Test
-    public void testOneSetOperand() throws Exception {
-        String sql = "SELECT * FROM tbl WHERE a = 1 ORDER BY b LIMIT 10";
-        org.apache.doris.analysis.SqlScanner input = new org.apache.doris.analysis.SqlScanner(
-                new StringReader(sql), 0L);
-        org.apache.doris.analysis.SqlParser parser = new org.apache.doris.analysis.SqlParser(input);
-        StatementBase statementBase = SqlParserUtils.getFirstStmt(parser);
-
-        Assertions.assertTrue(statementBase instanceof SelectStmt);
-        SelectStmt selectStmt = (SelectStmt) statementBase;
-        Assertions.assertEquals(10, selectStmt.getLimit());
-        Assertions.assertEquals(1, selectStmt.getOrderByElements().size());
-    }
-
-    @Test
-    public void testTwoSetOperandWithSecondInnerOrganization() throws Exception {
-        String sql = "SELECT * FROM tbl WHERE a = 1 UNION (SELECT * FROM tbl WHERE a = 2 ORDER BY b LIMIT 10)";
-        org.apache.doris.analysis.SqlScanner input = new org.apache.doris.analysis.SqlScanner(
-                new StringReader(sql), 0L);
-        org.apache.doris.analysis.SqlParser parser = new org.apache.doris.analysis.SqlParser(input);
-        StatementBase statementBase = SqlParserUtils.getFirstStmt(parser);
-
-        Assertions.assertTrue(statementBase instanceof SetOperationStmt);
-        SetOperationStmt setOperationStmt = (SetOperationStmt) statementBase;
-        Assertions.assertEquals(-1, setOperationStmt.getLimit());
-        Assertions.assertNull(setOperationStmt.getOrderByElements());
-        Assertions.assertEquals(2, setOperationStmt.getOperands().size());
-
-        QueryStmt secondQueryStmt = setOperationStmt.getOperands().get(1).getQueryStmt();
-        Assertions.assertEquals(10, secondQueryStmt.getLimit());
-        Assertions.assertEquals(1, secondQueryStmt.getOrderByElements().size());
-    }
-
-    @Test
-    public void testTwoSetOperandWithFirstInnerOrganization() throws Exception {
-        String sql = "(SELECT * FROM tbl WHERE a = 1  ORDER BY b LIMIT 10) UNION SELECT * FROM tbl WHERE a = 2";
-        org.apache.doris.analysis.SqlScanner input = new org.apache.doris.analysis.SqlScanner(
-                new StringReader(sql), 0L);
-        org.apache.doris.analysis.SqlParser parser = new org.apache.doris.analysis.SqlParser(input);
-        StatementBase statementBase = SqlParserUtils.getFirstStmt(parser);
-
-        Assertions.assertTrue(statementBase instanceof SetOperationStmt);
-        SetOperationStmt setOperationStmt = (SetOperationStmt) statementBase;
-        Assertions.assertEquals(-1, setOperationStmt.getLimit());
-        Assertions.assertNull(setOperationStmt.getOrderByElements());
-        Assertions.assertEquals(2, setOperationStmt.getOperands().size());
-
-        QueryStmt secondQueryStmt = setOperationStmt.getOperands().get(0).getQueryStmt();
-        Assertions.assertEquals(10, secondQueryStmt.getLimit());
-        Assertions.assertEquals(1, secondQueryStmt.getOrderByElements().size());
-    }
-
-    @Test
-    public void testTwoSetOperandWithOuterOrganization() throws Exception {
-        String sql = "SELECT * FROM tbl WHERE a = 1 UNION SELECT * FROM tbl WHERE a = 2 ORDER BY b LIMIT 10";
-        org.apache.doris.analysis.SqlScanner input = new org.apache.doris.analysis.SqlScanner(
-                new StringReader(sql), 0L);
-        org.apache.doris.analysis.SqlParser parser = new org.apache.doris.analysis.SqlParser(input);
-        StatementBase statementBase = SqlParserUtils.getFirstStmt(parser);
-
-        Assertions.assertTrue(statementBase instanceof SetOperationStmt);
-        SetOperationStmt setOperationStmt = (SetOperationStmt) statementBase;
-        Assertions.assertEquals(10, setOperationStmt.getLimit());
-        Assertions.assertEquals(1, setOperationStmt.getOrderByElements().size());
-        Assertions.assertEquals(2, setOperationStmt.getOperands().size());
-
-        QueryStmt secondQueryStmt = setOperationStmt.getOperands().get(1).getQueryStmt();
-        Assertions.assertEquals(-1, secondQueryStmt.getLimit());
-        Assertions.assertNull(secondQueryStmt.getOrderByElements());
-    }
-
-    @Test
-    public void testInvalidSyntax() throws Exception {
-        String sql = "SELECT * FROM tbl WHERE a = 1 ORDER BY b LIMIT 10 "
-                + "UNION SELECT * FROM tbl WHERE a = 2 ORDER BY b LIMIT 10";
-        org.apache.doris.analysis.SqlScanner input = new org.apache.doris.analysis.SqlScanner(
-                new StringReader(sql), 0L);
-        org.apache.doris.analysis.SqlParser parser = new org.apache.doris.analysis.SqlParser(input);
-
-        UserException thrown = Assertions.assertThrows(
-                UserException.class,
-                () -> SqlParserUtils.getFirstStmt(parser),
-                "Expected parser throw exception, but it didn't"
-        );
-
-        Assertions.assertTrue(thrown.getMessage().contains("Syntax error"));
-    }
-}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
index 4bd9917f63..b8ff587967 100755
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
@@ -780,7 +780,7 @@ public class SelectStmtTest {
         Assert.assertEquals("SELECT `t`.`k1` AS `k1` "
                 + "FROM (WITH v1 AS (SELECT `t1`.`k1` AS `k1` FROM `default_cluster:db1`.`tbl1` t1),"
                 + "v2 AS (SELECT `t2`.`k1` AS `k1` FROM `default_cluster:db1`.`tbl1` t2) "
-                + "(SELECT `v1`.`k1` AS `k1` FROM `v1`) UNION SELECT `v2`.`k1` AS `k1` FROM `v2`) t", stmt1.toSql());
+                + "SELECT `v1`.`k1` AS `k1` FROM `v1` UNION SELECT `v2`.`k1` AS `k1` FROM `v2`) t", stmt1.toSql());
 
         String sql2 =
                 "with\n"
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
index 3113845c22..8dac6ddaec 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateViewTest.java
@@ -91,14 +91,14 @@ public class CreateViewTest {
         // test union all
         ExceptionChecker.expectThrowsNoException(
                 () -> createView("create view test.view6 as "
-                        + "(select * from test.tbl1 where curdate() > '2021-06-26' order by k1 limit 10) "
+                        + "select * from test.tbl1 where curdate() > '2021-06-26' order by k1 limit 10 "
                         + "union all "
-                        + "(select * from test.tbl1 where curdate() > '2021-06-26' order by k2 limit 10, 50);"));
+                        + "select * from test.tbl1 where curdate() > '2021-06-26' order by k2 limit 10, 50;"));
         ExceptionChecker.expectThrowsNoException(
                 () -> createView("create view test.view7 (k1, k2) as "
-                        + "(select k1, k2 from test.tbl1 where curdate() > '2021-06-26' order by k1 limit 10) "
+                        + "select k1, k2 from test.tbl1 where curdate() > '2021-06-26' order by k1 limit 10 "
                         + "union all "
-                        + "(select k1, k2 from test.tbl1 where curdate() > '2021-06-26' order by k2 limit 10, 50);"));
+                        + "select k1, k2 from test.tbl1 where curdate() > '2021-06-26' order by k2 limit 10, 50;"));
 
         Database db = Env.getCurrentInternalCatalog().getDbOrDdlException("default_cluster:test");
 


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