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

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

commit 95da52b9d8cdc16e52ed5b312272a1be3d33d3ae
Author: Mingyu Chen <morning...@163.com>
AuthorDate: Mon Apr 1 11:01:29 2024 +0800

    [fix](avro) avoid BE crash if avro scanner's dependency jars is mssing 
(#33031)
    
    1. Check the return value of avro reader's init_fetch_table_schema_reader()
    2. Also fix a bug but the parse exception of Nereids may suppress the real 
exception from old planner
        It will result unable to see the real error msg.
---
 be/src/service/internal_service.cpp                          |  8 ++++++--
 .../src/main/java/org/apache/doris/qe/ConnectProcessor.java  | 12 +++++++++++-
 .../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, 22 insertions(+), 8 deletions(-)

diff --git a/be/src/service/internal_service.cpp 
b/be/src/service/internal_service.cpp
index f0249a60f82..16f592889c7 100644
--- a/be/src/service/internal_service.cpp
+++ b/be/src/service/internal_service.cpp
@@ -695,8 +695,7 @@ void 
PInternalServiceImpl::fetch_table_schema(google::protobuf::RpcController* c
             std::vector<SlotDescriptor*> file_slots;
             reader = vectorized::AvroJNIReader::create_unique(profile.get(), 
params, range,
                                                               file_slots);
-            static_cast<void>(
-                    
((vectorized::AvroJNIReader*)(reader.get()))->init_fetch_table_schema_reader());
+            st = 
((vectorized::AvroJNIReader*)(reader.get()))->init_fetch_table_schema_reader();
             break;
         }
         default:
@@ -705,6 +704,11 @@ void 
PInternalServiceImpl::fetch_table_schema(google::protobuf::RpcController* c
             st.to_protobuf(result->mutable_status());
             return;
         }
+        if (!st.ok()) {
+            LOG(WARNING) << "failed to init reader, errmsg=" << st;
+            st.to_protobuf(result->mutable_status());
+            return;
+        }
         std::vector<std::string> col_names;
         std::vector<TypeDescriptor> col_types;
         st = reader->get_parsed_schema(&col_names, &col_types);
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 c22d105a8be..6bf5aec217a 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
@@ -46,6 +46,7 @@ import org.apache.doris.mysql.MysqlPacket;
 import org.apache.doris.mysql.MysqlSerializer;
 import org.apache.doris.mysql.MysqlServerStatusFlag;
 import org.apache.doris.nereids.exceptions.NotSupportedException;
+import org.apache.doris.nereids.exceptions.ParseException;
 import org.apache.doris.nereids.glue.LogicalPlanAdapter;
 import org.apache.doris.nereids.minidump.MinidumpUtils;
 import org.apache.doris.nereids.parser.Dialect;
@@ -206,10 +207,19 @@ public abstract class ConnectProcessor {
                 // Parse sql failed, audit it and return
                 handleQueryException(e, convertedStmt, null, null);
                 return;
+            } catch (ParseException e) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Nereids parse sql failed. Reason: {}. 
Statement: \"{}\".",
+                            e.getMessage(), convertedStmt);
+                }
+                // ATTN: Do not set nereidsParseException in this case.
+                // Because ParseException means the sql is not supported by 
Nereids.
+                // It should be parsed by old parser, so not setting 
nereidsParseException to avoid
+                // suppressing the exception thrown by old parser.
             } catch (Exception e) {
                 // TODO: We should catch all exception here until we support 
all query syntax.
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("Nereids parse sql failed. Reason: {}. 
Statement: \"{}\".",
+                    LOG.debug("Nereids parse sql failed with other exception. 
Reason: {}. Statement: \"{}\".",
                             e.getMessage(), convertedStmt);
                 }
                 nereidsParseException = e;
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 0c620790e06..c890b27fada 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 "ParseException"
+        exception "Syntax error in line 1"
     }
 
     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 bc21c18a0a9..fdc93c4153e 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
@@ -52,6 +52,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 "ParseException"
+        exception "Sql parser can't convert the result to array"
     }
 }
diff --git a/regression-test/suites/demo_p0/test_action.groovy 
b/regression-test/suites/demo_p0/test_action.groovy
index db5de0229b8..1cae0da47e3 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 "ParseException"
+        exception "Syntax error in line 1"
     }
 
     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 db9529887dc..597facb3ea3 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 "ParseException"
+        exception "Syntax error in line 3"
     }
 }
diff --git a/regression-test/suites/query_p0/join/test_join2.groovy 
b/regression-test/suites/query_p0/join/test_join2.groovy
index 940a22bb912..fb8cdb95f00 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 "ParseException"
+        exception "natural join is not supported"
     }
     
     qt_join4 """


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

Reply via email to