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 2024/09/04 11:48:17 UTC

(doris) branch master updated: [chore](Nereids) do not fallback if parse failed for all case (#40331)

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

morrysnow 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 9963ec2ddfb [chore](Nereids) do not fallback if parse failed for all case (#40331)
9963ec2ddfb is described below

commit 9963ec2ddfbdf9143a6779febb1b6bf9c83e1baf
Author: morrySnow <10...@users.noreply.github.com>
AuthorDate: Wed Sep 4 19:48:10 2024 +0800

    [chore](Nereids) do not fallback if parse failed for all case (#40331)
---
 .../java/org/apache/doris/qe/ConnectProcessor.java | 47 ++++++++++------------
 .../datatype_p0/bitmap/test_bitmap_int.groovy      |  2 +-
 .../test_nestedtypes_insert_into_select.groovy     |  4 +-
 regression-test/suites/demo_p0/test_action.groovy  |  2 +-
 .../hive/ddl/test_hive_ddl.groovy                  |  2 +-
 .../update_on_current_timestamp.groovy             |  2 +-
 .../grouping_sets/test_grouping_sets.groovy        |  2 +-
 .../suites/query_p0/join/test_join2.groovy         |  2 +-
 8 files changed, 29 insertions(+), 34 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
index 91a3dbaad94..8f6faf41598 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
@@ -21,7 +21,6 @@ import org.apache.doris.analysis.ExplainOptions;
 import org.apache.doris.analysis.InsertStmt;
 import org.apache.doris.analysis.KillStmt;
 import org.apache.doris.analysis.LiteralExpr;
-import org.apache.doris.analysis.NotFallbackInParser;
 import org.apache.doris.analysis.QueryStmt;
 import org.apache.doris.analysis.SqlParser;
 import org.apache.doris.analysis.SqlScanner;
@@ -300,6 +299,27 @@ public abstract class ConnectProcessor {
                     nereidsSyntaxException = e;
                 }
             }
+
+            if (stmts == null && !ctx.getSessionVariable().enableFallbackToOriginalPlanner) {
+                String errMsg;
+                Throwable exception = null;
+                if (nereidsParseException != null) {
+                    errMsg = nereidsParseException.getMessage();
+                    exception = nereidsParseException;
+                } else if (nereidsSyntaxException != null) {
+                    errMsg = nereidsSyntaxException.getMessage();
+                    exception = nereidsSyntaxException;
+                } else {
+                    errMsg = "Nereids parse statements failed. " + originStmt;
+                }
+                if (exception == null) {
+                    exception = new AnalysisException(errMsg);
+                } else {
+                    exception = new AnalysisException(errMsg, exception);
+                }
+                handleQueryException(exception, originStmt, null, null);
+                return;
+            }
         }
 
         // stmts == null when Nereids cannot planner this query or Nereids is disabled.
@@ -325,31 +345,6 @@ public abstract class ConnectProcessor {
             }
         }
 
-        if (mysqlCommand == MysqlCommand.COM_QUERY
-                && ctx.getSessionVariable().isEnableNereidsPlanner()
-                && !ctx.getSessionVariable().enableFallbackToOriginalPlanner
-                && !stmts.isEmpty()
-                && stmts.stream().allMatch(s -> s instanceof NotFallbackInParser)) {
-            String errMsg;
-            Throwable exception = null;
-            if (nereidsParseException != null) {
-                errMsg = nereidsParseException.getMessage();
-                exception = nereidsParseException;
-            } else if (nereidsSyntaxException != null) {
-                errMsg = nereidsSyntaxException.getMessage();
-                exception = nereidsSyntaxException;
-            } else {
-                errMsg = "Nereids parse DQL failed. " + originStmt;
-            }
-            if (exception == null) {
-                exception = new AnalysisException(errMsg);
-            } else {
-                exception = new AnalysisException(errMsg, exception);
-            }
-            handleQueryException(exception, originStmt, null, null);
-            return;
-        }
-
         List<String> origSingleStmtList = null;
         // if stmts.size() > 1, split originStmt to multi singleStmts
         if (stmts.size() > 1) {
diff --git a/regression-test/suites/datatype_p0/bitmap/test_bitmap_int.groovy b/regression-test/suites/datatype_p0/bitmap/test_bitmap_int.groovy
index c890b27fada..38725987d96 100644
--- a/regression-test/suites/datatype_p0/bitmap/test_bitmap_int.groovy
+++ b/regression-test/suites/datatype_p0/bitmap/test_bitmap_int.groovy
@@ -68,7 +68,7 @@ suite("test_bitmap_int") {
 
     test {
         sql """SELECT case id_bitmap when 1 then 1 else 0 FROM test_bitmap;"""
-        exception "Syntax error in line 1"
+        exception "missing 'END' at 'FROM'"
     }
 
     qt_sql64_4 """SELECT id_bitmap  FROM test_bitmap  WHERE id_bitmap is null LIMIT 20;"""
diff --git a/regression-test/suites/datatype_p0/nested_types/query/test_nestedtypes_insert_into_select.groovy b/regression-test/suites/datatype_p0/nested_types/query/test_nestedtypes_insert_into_select.groovy
index 2023ecf641c..633ad98d86f 100644
--- a/regression-test/suites/datatype_p0/nested_types/query/test_nestedtypes_insert_into_select.groovy
+++ b/regression-test/suites/datatype_p0/nested_types/query/test_nestedtypes_insert_into_select.groovy
@@ -32,7 +32,7 @@ suite("test_nestedtypes_insert_into_select", "p0") {
 
     test {
         sql "insert into ast values ('text' , [named_struct('a',1,'b','home'),named_struct('a',2,'b','work')]);"
-        exception "errCode = 2, detailMessage = Sql parser can't convert the result to array, please check your sql."
+        exception "mismatched input 'named_struct' expecting"
     }
 
 
@@ -50,6 +50,6 @@ suite("test_nestedtypes_insert_into_select", "p0") {
 
     test {
         sql "insert into ast values ('text' , [named_struct('a',1,'b','home'),named_struct('a',2,'b','work')]);"
-        exception "Sql parser can't convert the result to array"
+        exception "mismatched input 'named_struct' expecting"
     }
 }
diff --git a/regression-test/suites/demo_p0/test_action.groovy b/regression-test/suites/demo_p0/test_action.groovy
index 1cae0da47e3..7f0d4d7eb8b 100644
--- a/regression-test/suites/demo_p0/test_action.groovy
+++ b/regression-test/suites/demo_p0/test_action.groovy
@@ -19,7 +19,7 @@ suite("test_action") {
     test {
         sql "abcdefg"
         // check exception message contains
-        exception "Syntax error in line 1"
+        exception "extraneous input 'abcdefg'"
     }
 
     test {
diff --git a/regression-test/suites/external_table_p0/hive/ddl/test_hive_ddl.groovy b/regression-test/suites/external_table_p0/hive/ddl/test_hive_ddl.groovy
index aa4d8c0b3c6..1d39ab9cde5 100644
--- a/regression-test/suites/external_table_p0/hive/ddl/test_hive_ddl.groovy
+++ b/regression-test/suites/external_table_p0/hive/ddl/test_hive_ddl.groovy
@@ -362,7 +362,7 @@ suite("test_hive_ddl", "p0,external,hive,external_docker,external_docker_hive")
                 sql """
                         CREATE TABLE schema_check ENGINE=hive ;
                     """
-                exception "AnalysisException, msg: Should contain at least one column in a table"
+                exception "Should contain at least one column in a table"
             }
             sql """ DROP DATABASE IF EXISTS `test_hive_loc` """
         }
diff --git a/regression-test/suites/nereids_p0/insert_into_table/update_on_current_timestamp.groovy b/regression-test/suites/nereids_p0/insert_into_table/update_on_current_timestamp.groovy
index 597facb3ea3..ef5496a7a76 100644
--- a/regression-test/suites/nereids_p0/insert_into_table/update_on_current_timestamp.groovy
+++ b/regression-test/suites/nereids_p0/insert_into_table/update_on_current_timestamp.groovy
@@ -190,6 +190,6 @@ suite("nereids_update_on_current_timestamp") {
                 k int,
                 `update_time` datetime(6) default current_timestamp(4) on update current_timestamp(3)) replace,
             ) AGGREGATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" = "1");"""
-        exception "Syntax error in line 3"
+        exception "mismatched input 'replace'"
     }
 }
diff --git a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
index 76a74760800..85bfae6a13c 100644
--- a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
+++ b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets.groovy
@@ -98,7 +98,7 @@ suite("test_grouping_sets", "p0") {
             SELECT k1, k3, MAX( k8 ) FROM test_query_db.test 
             GROUP BY k1, GROUPING SETS ( (k1, k3), (k1), ( ) ), ROLLUP(k1, k3)
             """
-        exception "Syntax error"
+        exception "mismatched input 'SETS'"
     }
 
     qt_select13"""
diff --git a/regression-test/suites/query_p0/join/test_join2.groovy b/regression-test/suites/query_p0/join/test_join2.groovy
index fb8cdb95f00..9158133948f 100644
--- a/regression-test/suites/query_p0/join/test_join2.groovy
+++ b/regression-test/suites/query_p0/join/test_join2.groovy
@@ -84,7 +84,7 @@ suite("test_join2", "query,p0,arrow_flight_sql") {
             FROM ${TBname1} NATURAL JOIN ${TBname2}
             ORDER BY 1,2,3,4,5,6;
         """
-        exception "natural join is not supported"
+        exception "mismatched input 'NATURAL'"
     }
     
     qt_join4 """


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