From c24b010eac2ab62c33fcfbc700f7506421c2a02f Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:10:56 +0800 Subject: [PATCH] [fix](be)confix bug of converting outer join probe block to nullable (#25492) _do_evaluate will add temp result column into original table block, so in order to only convert correct columns to be nullable, need call convert_block_to_null before _do_evaluate --- .../pipeline/exec/hashjoin_probe_operator.cpp | 5 ++-- be/src/vec/exec/join/vhash_join_node.cpp | 4 ++-- .../test_outer_join_with_inline_view.out | 3 +++ .../test_outer_join_with_inline_view.groovy | 23 +++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/be/src/pipeline/exec/hashjoin_probe_operator.cpp b/be/src/pipeline/exec/hashjoin_probe_operator.cpp index c4b009f7389542..3d0ea8a4ffc8b5 100644 --- a/be/src/pipeline/exec/hashjoin_probe_operator.cpp +++ b/be/src/pipeline/exec/hashjoin_probe_operator.cpp @@ -465,12 +465,13 @@ Status HashJoinProbeOperatorX::push(RuntimeState* state, vectorized::Block* inpu local_state._probe_columns.resize(probe_expr_ctxs_sz); std::vector res_col_ids(probe_expr_ctxs_sz); - RETURN_IF_ERROR(_do_evaluate(*input_block, local_state._probe_expr_ctxs, - *local_state._probe_expr_call_timer, res_col_ids)); if (_join_op == TJoinOp::RIGHT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) { local_state._probe_column_convert_to_null = local_state._dependency->convert_block_to_null(*input_block); } + RETURN_IF_ERROR(_do_evaluate(*input_block, local_state._probe_expr_ctxs, + *local_state._probe_expr_call_timer, res_col_ids)); + // TODO: Now we are not sure whether a column is nullable only by ExecNode's `row_desc` // so we have to initialize this flag by the first probe block. if (!local_state._has_set_need_null_map_for_probe) { diff --git a/be/src/vec/exec/join/vhash_join_node.cpp b/be/src/vec/exec/join/vhash_join_node.cpp index af7336a1f5ee77..f0427a16bd9dd3 100644 --- a/be/src/vec/exec/join/vhash_join_node.cpp +++ b/be/src/vec/exec/join/vhash_join_node.cpp @@ -502,11 +502,11 @@ Status HashJoinNode::push(RuntimeState* /*state*/, vectorized::Block* input_bloc _probe_columns.resize(probe_expr_ctxs_sz); std::vector res_col_ids(probe_expr_ctxs_sz); - RETURN_IF_ERROR( - _do_evaluate(*input_block, _probe_expr_ctxs, *_probe_expr_call_timer, res_col_ids)); if (_join_op == TJoinOp::RIGHT_OUTER_JOIN || _join_op == TJoinOp::FULL_OUTER_JOIN) { _probe_column_convert_to_null = _convert_block_to_null(*input_block); } + RETURN_IF_ERROR( + _do_evaluate(*input_block, _probe_expr_ctxs, *_probe_expr_call_timer, res_col_ids)); // TODO: Now we are not sure whether a column is nullable only by ExecNode's `row_desc` // so we have to initialize this flag by the first probe block. if (!_has_set_need_null_map_for_probe) { diff --git a/regression-test/data/correctness_p0/test_outer_join_with_inline_view.out b/regression-test/data/correctness_p0/test_outer_join_with_inline_view.out index 4e9d0de8b99916..65d1434de7be6d 100644 --- a/regression-test/data/correctness_p0/test_outer_join_with_inline_view.out +++ b/regression-test/data/correctness_p0/test_outer_join_with_inline_view.out @@ -14,3 +14,6 @@ -- !select_with_agg_in_inline_view_and_outer_join -- 1 +-- !select_with_outerjoin_nullable -- +2023-10-07 + diff --git a/regression-test/suites/correctness_p0/test_outer_join_with_inline_view.groovy b/regression-test/suites/correctness_p0/test_outer_join_with_inline_view.groovy index 3d8c563f0d5495..a2d665451228ae 100644 --- a/regression-test/suites/correctness_p0/test_outer_join_with_inline_view.groovy +++ b/regression-test/suites/correctness_p0/test_outer_join_with_inline_view.groovy @@ -158,4 +158,27 @@ suite("test_outer_join_with_inline_view") { group by aa.org_code; """ + + sql """set enable_nereids_planner=false;""" + sql """drop table if exists tableau_trans_wide_day_month_year;""" + sql """CREATE TABLE + `tableau_trans_wide_day_month_year` ( + `business_type` varchar(200) NULL + ) ENGINE = OLAP + DUPLICATE KEY(`business_type`) + DISTRIBUTED BY HASH(`business_type`) BUCKETS 15 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + sql """INSERT INTO `tableau_trans_wide_day_month_year` VALUES (NULL);""" + qt_select_with_outerjoin_nullable """ SELECT '2023-10-07' a + FROM + (SELECT t.business_type + FROM tableau_trans_wide_day_month_year t ) a full + JOIN + (SELECT t.business_type + FROM tableau_trans_wide_day_month_year t + WHERE false ) c + ON nvl(a.business_type,'0')=nvl(c.business_type,'0'); """ + sql """drop table if exists tableau_trans_wide_day_month_year;""" }