Skip to content

Commit

Permalink
[fix](be)confix bug of converting outer join probe block to nullable (a…
Browse files Browse the repository at this point in the history
…pache#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
  • Loading branch information
starocean999 authored and wsjz committed Nov 19, 2023
1 parent 0572117 commit c24b010
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
5 changes: 3 additions & 2 deletions be/src/pipeline/exec/hashjoin_probe_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,13 @@ Status HashJoinProbeOperatorX::push(RuntimeState* state, vectorized::Block* inpu
local_state._probe_columns.resize(probe_expr_ctxs_sz);

std::vector<int> 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) {
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/exec/join/vhash_join_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@ Status HashJoinNode::push(RuntimeState* /*state*/, vectorized::Block* input_bloc
_probe_columns.resize(probe_expr_ctxs_sz);

std::vector<int> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
-- !select_with_agg_in_inline_view_and_outer_join --
1

-- !select_with_outerjoin_nullable --
2023-10-07

Original file line number Diff line number Diff line change
Expand Up @@ -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;"""
}

0 comments on commit c24b010

Please sign in to comment.