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

yiguolei 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 47955f9109f [bug](intersect) fix intersect node nullable field should 
depend on _row_descriptor (#26038)
47955f9109f is described below

commit 47955f9109fb6fdf955c86911c09d8746156e29e
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Sat Oct 28 22:39:36 2023 +0800

    [bug](intersect) fix intersect node nullable field should depend on 
_row_descriptor (#26038)
---
 be/src/pipeline/exec/set_source_operator.cpp       | 16 +++---
 be/src/vec/exec/vset_operation_node.cpp            | 16 +++---
 .../data/correctness_p0/test_set_operation.out     |  8 +++
 .../correctness_p0/test_set_operation.groovy       | 58 ++++++++++++++++++++++
 4 files changed, 86 insertions(+), 12 deletions(-)

diff --git a/be/src/pipeline/exec/set_source_operator.cpp 
b/be/src/pipeline/exec/set_source_operator.cpp
index 31d372a002a..e679274d92c 100644
--- a/be/src/pipeline/exec/set_source_operator.cpp
+++ b/be/src/pipeline/exec/set_source_operator.cpp
@@ -67,13 +67,17 @@ Status 
SetSourceLocalState<is_intersect>::open(RuntimeState* state) {
     SCOPED_TIMER(_open_timer);
     RETURN_IF_ERROR(PipelineXLocalState<SetDependency>::open(state));
     auto& child_exprs_lists = _shared_state->child_exprs_lists;
-    vector<bool> nullable_flags;
 
-    nullable_flags.resize(child_exprs_lists[0].size(), false);
-    for (int i = 0; i < child_exprs_lists.size(); ++i) {
-        for (int j = 0; j < child_exprs_lists[i].size(); ++j) {
-            nullable_flags[j] = nullable_flags[j] || 
child_exprs_lists[i][j]->root()->is_nullable();
-        }
+    auto output_data_types = vectorized::VectorizedUtils::get_data_types(
+            _parent->cast<SetSourceOperatorX<is_intersect>>()._row_descriptor);
+    auto column_nums = child_exprs_lists[0].size();
+    DCHECK_EQ(output_data_types.size(), column_nums)
+            << output_data_types.size() << " " << column_nums;
+    // the nullable is not depend on child, it's should use _row_descriptor 
from FE plan
+    // some case all not nullable column from children, but maybe need output 
nullable.
+    vector<bool> nullable_flags(column_nums, false);
+    for (int i = 0; i < column_nums; ++i) {
+        nullable_flags[i] = output_data_types[i]->is_nullable();
     }
 
     _left_table_data_types.clear();
diff --git a/be/src/vec/exec/vset_operation_node.cpp 
b/be/src/vec/exec/vset_operation_node.cpp
index f12669336cf..791e92679d0 100644
--- a/be/src/vec/exec/vset_operation_node.cpp
+++ b/be/src/vec/exec/vset_operation_node.cpp
@@ -160,14 +160,18 @@ Status 
VSetOperationNode<is_intersect>::prepare(RuntimeState* state) {
     _build_timer = ADD_TIMER(runtime_profile(), "BuildTime");
     _probe_timer = ADD_TIMER(runtime_profile(), "ProbeTime");
     _pull_timer = ADD_TIMER(runtime_profile(), "PullTime");
+    auto output_data_types = VectorizedUtils::get_data_types(_row_descriptor);
+    auto column_nums = _child_expr_lists[0].size();
+    DCHECK_EQ(output_data_types.size(), column_nums)
+            << output_data_types.size() << " " << column_nums;
+    // the nullable is not depend on child, it's should use _row_descriptor 
from FE plan
+    // some case all not nullable column from children, but maybe need output 
nullable.
+    vector<bool> nullable_flags(column_nums, false);
+    for (int i = 0; i < column_nums; ++i) {
+        nullable_flags[i] = output_data_types[i]->is_nullable();
+    }
 
-    // Prepare result expr lists.
-    vector<bool> nullable_flags;
-    nullable_flags.resize(_child_expr_lists[0].size(), false);
     for (int i = 0; i < _child_expr_lists.size(); ++i) {
-        for (int j = 0; j < _child_expr_lists[i].size(); ++j) {
-            nullable_flags[j] = nullable_flags[j] || 
_child_expr_lists[i][j]->root()->is_nullable();
-        }
         RETURN_IF_ERROR(VExpr::prepare(_child_expr_lists[i], state, 
child(i)->row_desc()));
     }
     for (int i = 0; i < _child_expr_lists[0].size(); ++i) {
diff --git a/regression-test/data/correctness_p0/test_set_operation.out 
b/regression-test/data/correctness_p0/test_set_operation.out
index 095c7b20356..f6d9f32d4cc 100644
--- a/regression-test/data/correctness_p0/test_set_operation.out
+++ b/regression-test/data/correctness_p0/test_set_operation.out
@@ -2,3 +2,11 @@
 -- !sql --
 1
 
+-- !select1 --
+aaaa
+bbbb
+
+-- !select1 --
+aaaa
+bbbb
+
diff --git a/regression-test/suites/correctness_p0/test_set_operation.groovy 
b/regression-test/suites/correctness_p0/test_set_operation.groovy
index cd366f4d2bf..e3e28a9e3a4 100644
--- a/regression-test/suites/correctness_p0/test_set_operation.groovy
+++ b/regression-test/suites/correctness_p0/test_set_operation.groovy
@@ -67,4 +67,62 @@ suite("test_set_operation") {
                     WHERE a = 3 ) ) ) ) c
                 ORDER BY  one_uid;
     """
+
+    sql """
+        drop table if exists test_A;
+    """
+
+    sql """
+        drop table if exists test_B;
+    """
+
+    sql """
+        CREATE TABLE `test_A` ( 
+        `stat_day` varchar(200) NOT NULL ,
+        `sku_code` varchar(200) NOT NULL ,
+        `site_code` varchar(200) NOT NULL )
+        ENGINE = OLAP DUPLICATE KEY(`stat_day`) COMMENT '' 
+        DISTRIBUTED BY HASH(`stat_day`,`sku_code`,`site_code`) BUCKETS 16 
+        PROPERTIES ( 
+        "replication_allocation" = "tag.location.default: 1",
+        "is_being_synced" = "false",
+        "storage_format" = "V2",
+        "disable_auto_compaction" = "false",
+        "enable_single_replica_compaction" = "false" );
+    """
+
+
+    sql """
+        CREATE TABLE `test_B` ( 
+        `stat_day` varchar(200) NULL,
+        `sku_code` varchar(200) NULL ) 
+        ENGINE = OLAP DUPLICATE KEY(`stat_day`) COMMENT '-' 
+        DISTRIBUTED BY HASH(`stat_day`,`sku_code`) BUCKETS 16 
+        PROPERTIES ( 
+        "replication_allocation" = "tag.location.default: 1",
+        "is_being_synced" = "false",
+        "storage_format" = "V2",
+        "disable_auto_compaction" = "false",
+        "enable_single_replica_compaction" = "false" );
+    """
+
+    sql """
+        insert into test_A values("aa","aaaa","aaaaaa");
+    """
+
+    sql """
+        insert into test_B values("bb","bbbb");
+    """
+
+    sql """
+        set experimental_enable_nereids_planner = false;
+    """
+
+    qt_select1  """  SELECT DISTINCT * FROM((SELECT sku_code FROM test_B) 
INTERSECT (SELECT sku_code FROM test_B) UNION (SELECT sku_code FROM test_A)) as 
t order by 1; """
+
+    sql """
+        set experimental_enable_nereids_planner = true;
+    """
+    qt_select1  """  SELECT DISTINCT * FROM((SELECT sku_code FROM test_B) 
INTERSECT (SELECT sku_code FROM test_B) UNION (SELECT sku_code FROM test_A)) as 
t order by 1; """
+
 }


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

Reply via email to