Skip to content

Commit

Permalink
[bug](join) fix outer join not add tuple is null column when build ro…
Browse files Browse the repository at this point in the history
…ws is 0 (apache#23974)

fix outer join not add tuple is null column when build rows is 0
  • Loading branch information
zhangstar333 authored Sep 8, 2023
1 parent 69868f1 commit 76ca57c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
37 changes: 21 additions & 16 deletions be/src/vec/exec/join/vhash_join_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,17 +483,17 @@ Status HashJoinNode::pull(doris::RuntimeState* state, vectorized::Block* output_
temp_block.insert({std::move(nullable_column), make_nullable(type),
_right_table_column_names[i]});
}

{
SCOPED_TIMER(_join_filter_timer);
RETURN_IF_ERROR(
VExprContext::filter_block(_conjuncts, &temp_block, temp_block.columns()));
if (_is_outer_join) {
reinterpret_cast<ColumnUInt8*>(_tuple_is_null_left_flag_column.get())
->get_data()
.resize_fill(block_rows, 0);
reinterpret_cast<ColumnUInt8*>(_tuple_is_null_right_flag_column.get())
->get_data()
.resize_fill(block_rows, 1);
}

RETURN_IF_ERROR(_build_output_block(&temp_block, output_block, false));
RETURN_IF_ERROR(_filter_data_and_build_output(state, output_block, eos, &temp_block));
temp_block.clear();
release_block_memory(_probe_block);
reached_limit(output_block, eos);
return Status::OK();
}
_join_block.clear_column_data();
Expand Down Expand Up @@ -570,22 +570,27 @@ Status HashJoinNode::pull(doris::RuntimeState* state, vectorized::Block* output_
if (!st) {
return st;
}
RETURN_IF_ERROR(_filter_data_and_build_output(state, output_block, eos, &temp_block));
// Here make _join_block release the columns' ptr
_join_block.set_columns(_join_block.clone_empty_columns());
mutable_join_block.clear();
return Status::OK();
}

Status HashJoinNode::_filter_data_and_build_output(RuntimeState* state,
vectorized::Block* output_block, bool* eos,
Block* temp_block) {
if (_is_outer_join) {
_add_tuple_is_null_column(&temp_block);
_add_tuple_is_null_column(temp_block);
}
auto output_rows = temp_block.rows();
auto output_rows = temp_block->rows();
DCHECK(output_rows <= state->batch_size());
{
SCOPED_TIMER(_join_filter_timer);
RETURN_IF_ERROR(VExprContext::filter_block(_conjuncts, &temp_block, temp_block.columns()));
RETURN_IF_ERROR(VExprContext::filter_block(_conjuncts, temp_block, temp_block->columns()));
}

// Here make _join_block release the columns' ptr
_join_block.set_columns(_join_block.clone_empty_columns());
mutable_join_block.clear();
RETURN_IF_ERROR(_build_output_block(&temp_block, output_block, false));

RETURN_IF_ERROR(_build_output_block(temp_block, output_block, false));
_reset_tuple_is_null_column();
reached_limit(output_block, eos);
return Status::OK();
Expand Down
3 changes: 3 additions & 0 deletions be/src/vec/exec/join/vhash_join_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ class HashJoinNode final : public VJoinNodeBase {
// add tuple is null flag column to Block for filter conjunct and output expr
void _add_tuple_is_null_column(Block* block) override;

Status _filter_data_and_build_output(RuntimeState* state, vectorized::Block* output_block,
bool* eos, Block* temp_block);

template <class HashTableContext>
friend struct ProcessHashTableBuild;

Expand Down

0 comments on commit 76ca57c

Please sign in to comment.