From f6ec05a19c50d3b26dcc689d9bf41057a9ce5b9c Mon Sep 17 00:00:00 2001 From: zhangdong <493738387@qq.com> Date: Mon, 18 Dec 2023 19:26:24 +0800 Subject: [PATCH] 1 --- .../main/java/org/apache/doris/qe/ConnectProcessor.java | 9 ++++++++- .../suites/correctness_p0/test_current_timestamp.groovy | 2 +- .../suites/datatype_p0/bitmap/test_bitmap_int.groovy | 2 +- .../query/test_nestedtypes_insert_into_select.groovy | 2 +- regression-test/suites/demo_p0/test_action.groovy | 2 +- .../insert_into_table/update_on_current_timestamp.groovy | 2 +- regression-test/suites/query_p0/join/test_join2.groovy | 2 +- 7 files changed, 14 insertions(+), 7 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 b019657bca8f2c..029149dfa75dea 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 @@ -179,7 +179,7 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) { .setSqlHash(ctx.getSqlHash()); List stmts = null; - + Exception nereidsParseException = null; // Nereids do not support prepare and execute now, so forbid prepare command, only process query command if (mysqlCommand == MysqlCommand.COM_QUERY && ctx.getSessionVariable().isEnableNereidsPlanner()) { try { @@ -192,6 +192,7 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) { // TODO: We should catch all exception here until we support all query syntax. LOG.debug("Nereids parse sql failed. Reason: {}. Statement: \"{}\".", e.getMessage(), originStmt); + nereidsParseException = e; } } @@ -200,6 +201,12 @@ protected void handleQuery(MysqlCommand mysqlCommand, String originStmt) { try { stmts = parse(originStmt); } catch (Throwable throwable) { + // if NereidsParser and oldParser both failed, + // prove is a new feature implemented only on the nereids, + // so an error message for the new nereids is thrown + if (nereidsParseException != null) { + throwable = nereidsParseException; + } // Parse sql failed, audit it and return handleQueryException(throwable, originStmt, null, null); return; diff --git a/regression-test/suites/correctness_p0/test_current_timestamp.groovy b/regression-test/suites/correctness_p0/test_current_timestamp.groovy index 6471f866169f9c..f1ec942356ff3c 100644 --- a/regression-test/suites/correctness_p0/test_current_timestamp.groovy +++ b/regression-test/suites/correctness_p0/test_current_timestamp.groovy @@ -213,7 +213,7 @@ suite("test_current_timestamp") { DISTRIBUTED BY HASH(id) PROPERTIES("replication_num" = "1"); """ - exception "errCode = 2, detailMessage = Internal Error, maybe syntax error or this is a bug: column's default value current_timestamp precision must be between 0 and 6" + exception "between 0 and 6" } // user case 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 0b0d577d1978f5..0c620790e0679e 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 "errCode" + exception "ParseException" } 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 3efb9d5b06f9c5..a74687af64e5ea 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 @@ -53,6 +53,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 "errCode = 2, detailMessage = Sql parser can't convert the result to array, please check your sql." + exception "ParseException" } } diff --git a/regression-test/suites/demo_p0/test_action.groovy b/regression-test/suites/demo_p0/test_action.groovy index 8a2d415e7ff84c..db5de0229b8b19 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 "errCode = 2, detailMessage = Syntax error" + exception "ParseException" } test { 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 35a68338835a6f..db9529887dc303 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" + exception "ParseException" } } diff --git a/regression-test/suites/query_p0/join/test_join2.groovy b/regression-test/suites/query_p0/join/test_join2.groovy index b64d40995a4d3c..940a22bb9123ef 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 "errCode = 2, detailMessage = natural join is not supported, please use inner join instead." + exception "ParseException" } qt_join4 """