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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 7bdc508ac7d [Bug](fix) fix coredump case in (not null, null) execpt 
(not null, not null) case (#38756)
7bdc508ac7d is described below

commit 7bdc508ac7d459faa144ba26147ac748b707dad8
Author: HappenLee <[email protected]>
AuthorDate: Sun Aug 4 10:44:10 2024 +0800

    [Bug](fix) fix coredump case in (not null, null) execpt (not null, not 
null) case (#38756)
    
    ## Proposed changes
    
    Issue Number: close #38612
    
    <!--Describe your changes.-->
---
 be/src/pipeline/exec/set_sink_operator.cpp                      | 8 ++++++--
 be/src/pipeline/pipeline_x/dependency.h                         | 4 +++-
 be/src/vec/exec/vset_operation_node.cpp                         | 6 ++++--
 regression-test/data/query_p0/except/test_query_except.out      | 2 ++
 regression-test/suites/query_p0/except/test_query_except.groovy | 3 +++
 5 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/be/src/pipeline/exec/set_sink_operator.cpp 
b/be/src/pipeline/exec/set_sink_operator.cpp
index aceeac25596..18515191388 100644
--- a/be/src/pipeline/exec/set_sink_operator.cpp
+++ b/be/src/pipeline/exec/set_sink_operator.cpp
@@ -140,9 +140,13 @@ Status 
SetSinkOperatorX<is_intersect>::_extract_build_column(
 
         block.get_by_position(result_col_id).column =
                 
block.get_by_position(result_col_id).column->convert_to_full_column_if_const();
+        // Do make nullable should not change the origin column and type in 
origin block
+        // which may cause coredump problem
         if (local_state._shared_state->build_not_ignore_null[i]) {
-            block.get_by_position(result_col_id).column =
-                    make_nullable(block.get_by_position(result_col_id).column);
+            auto column_ptr = 
make_nullable(block.get_by_position(result_col_id).column, false);
+            block.insert(
+                    {column_ptr, 
make_nullable(block.get_by_position(result_col_id).type), ""});
+            result_col_id = block.columns() - 1;
         }
 
         const auto* column = block.get_by_position(result_col_id).column.get();
diff --git a/be/src/pipeline/pipeline_x/dependency.h 
b/be/src/pipeline/pipeline_x/dependency.h
index b43ddb653a8..ba0d0962002 100644
--- a/be/src/pipeline/pipeline_x/dependency.h
+++ b/be/src/pipeline/pipeline_x/dependency.h
@@ -672,10 +672,12 @@ public:
         // (select 0) intersect (select null) the build side hash table should 
not
         // ignore null value.
         std::vector<DataTypePtr> data_types;
+        int i = 0;
         for (const auto& ctx : child_exprs_lists[0]) {
-            data_types.emplace_back(build_not_ignore_null[0]
+            data_types.emplace_back(build_not_ignore_null[i]
                                             ? 
make_nullable(ctx->root()->data_type())
                                             : ctx->root()->data_type());
+            i++;
         }
         if (!try_get_hash_map_context_fixed<NormalHashMap, HashCRC32, 
RowRefListWithFlags>(
                     *hash_table_variants, data_types)) {
diff --git a/be/src/vec/exec/vset_operation_node.cpp 
b/be/src/vec/exec/vset_operation_node.cpp
index afc3273f459..2f3c9b2bab3 100644
--- a/be/src/vec/exec/vset_operation_node.cpp
+++ b/be/src/vec/exec/vset_operation_node.cpp
@@ -421,8 +421,10 @@ Status 
VSetOperationNode<is_intersect>::extract_build_column(Block& block,
         block.get_by_position(result_col_id).column =
                 
block.get_by_position(result_col_id).column->convert_to_full_column_if_const();
         if (_build_not_ignore_null[i]) {
-            block.get_by_position(result_col_id).column =
-                    make_nullable(block.get_by_position(result_col_id).column);
+            auto column_ptr = 
make_nullable(block.get_by_position(result_col_id).column, false);
+            block.insert(
+                    {column_ptr, 
make_nullable(block.get_by_position(result_col_id).type), ""});
+            result_col_id = block.columns() - 1;
         }
         const auto* column = block.get_by_position(result_col_id).column.get();
         raw_ptrs[i] = column;
diff --git a/regression-test/data/query_p0/except/test_query_except.out 
b/regression-test/data/query_p0/except/test_query_except.out
index 7aea45fde18..763cb44c7f8 100644
--- a/regression-test/data/query_p0/except/test_query_except.out
+++ b/regression-test/data/query_p0/except/test_query_except.out
@@ -14,3 +14,5 @@
 14
 15
 
+-- !select_except2 --
+
diff --git a/regression-test/suites/query_p0/except/test_query_except.groovy 
b/regression-test/suites/query_p0/except/test_query_except.groovy
index a13fd76e7a9..410e24f89b9 100644
--- a/regression-test/suites/query_p0/except/test_query_except.groovy
+++ b/regression-test/suites/query_p0/except/test_query_except.groovy
@@ -22,4 +22,7 @@ suite("test_query_except", "arrow_flight_sql") {
                       SELECT * FROM (SELECT k1 FROM test_query_db.baseall
                                      EXCEPT SELECT k1 FROM test_query_db.test) 
a ORDER BY k1
                       """
+    qt_select_except2 """
+                     select not_null_k1, not_null_k1 from (SELECT 
non_nullable(k1) as not_null_k1 FROM test_query_db.baseall where k1 is not 
null) b1 except select non_nullable(k1), k1 from test_query_db.baseall where k1 
is not null order by 1, 2;        
+                     """
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to