Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions be/src/exec/operator/hashjoin_build_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,12 @@ Status HashJoinBuildSinkOperatorX::init(const TPlanNode& tnode, RuntimeState* st

Status HashJoinBuildSinkOperatorX::prepare(RuntimeState* state) {
RETURN_IF_ERROR(JoinBuildSinkOperatorX<HashJoinBuildSinkLocalState>::prepare(state));
if (_is_broadcast_join && (_match_all_build || _is_right_semi_anti)) {
return Status::NotSupported(
"Broadcast hash join does not support {} because build-side rows must be "
"finalized exactly once",
to_string(_join_op));
}
_use_shared_hash_table =
_is_broadcast_join && state->enable_share_hash_table_for_broadcast_join();
auto init_keep_column_flags = [&](auto& tuple_descs, auto& output_slot_flags) {
Expand Down
28 changes: 28 additions & 0 deletions be/test/exec/operator/hashjoin_build_sink_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,34 @@ TEST_F(HashJoinBuildSinkTest, Init) {
run_test_block(test_block);
}

TEST_F(HashJoinBuildSinkTest, RejectBroadcastJoinThatRequiresBuildSideFinalize) {
for (const auto join_op : {TJoinOp::RIGHT_OUTER_JOIN, TJoinOp::FULL_OUTER_JOIN,
TJoinOp::RIGHT_SEMI_JOIN, TJoinOp::RIGHT_ANTI_JOIN}) {
auto tnode =
_helper.create_test_plan_node(join_op, {TPrimitiveType::INT}, {false}, {false});
tnode.hash_join_node.__set_is_broadcast_join(true);

auto [probe_operator, sink_operator] = _helper.create_operators(tnode);
ASSERT_TRUE(probe_operator);
ASSERT_TRUE(sink_operator);

auto runtime_state = std::make_unique<MockRuntimeState>();
runtime_state->_query_ctx = _helper.query_ctx.get();
runtime_state->_query_id = _helper.query_ctx->query_id();
runtime_state->resize_op_id_to_local_state(-100);
runtime_state->set_max_operator_id(-100);
runtime_state->set_desc_tbl(_helper.desc_tbl);

auto st = sink_operator->init(tnode, runtime_state.get());
ASSERT_TRUE(st.ok()) << "init failed: " << st.to_string();

st = sink_operator->prepare(runtime_state.get());
ASSERT_TRUE(st.is<ErrorCode::NOT_IMPLEMENTED_ERROR>())
<< "broadcast " << to_string(join_op)
<< " should be rejected, got: " << st.to_string();
}
}

TEST_F(HashJoinBuildSinkTest, Sink) {
auto test_block = [&](TJoinOp::type op_type, const std::vector<TPrimitiveType::type>& key_types,
const std::vector<bool>& left_nullables,
Expand Down
Loading