From 86d5fc4f5eb7cf77fa5708189ef09fac92ba975c Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Thu, 21 Mar 2024 17:25:22 +0800 Subject: [PATCH] [fix](join) core caused by null-safe-equal join --- be/src/pipeline/exec/hashjoin_build_sink.cpp | 16 +++++++++++++++- .../common/hash_table/hash_map_context_creator.h | 15 ++++++++++++--- be/src/vec/exec/join/vhash_join_node.cpp | 12 +++++++++++- .../join/test_half_join_nullable_build_side.out | 8 ++++++++ .../test_half_join_nullable_build_side.groovy | 9 +++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/be/src/pipeline/exec/hashjoin_build_sink.cpp b/be/src/pipeline/exec/hashjoin_build_sink.cpp index b3ee878a941c21..dab127c2c5027e 100644 --- a/be/src/pipeline/exec/hashjoin_build_sink.cpp +++ b/be/src/pipeline/exec/hashjoin_build_sink.cpp @@ -361,8 +361,22 @@ void HashJoinBuildSinkLocalState::_hash_table_init(RuntimeState* state) { } return; } + + std::vector data_types; + for (size_t i = 0; i != _build_expr_ctxs.size(); ++i) { + auto& ctx = _build_expr_ctxs[i]; + auto data_type = ctx->root()->data_type(); + + /// For 'null safe equal' join, + /// the build key column maybe be converted to nullable from non-nullable. + if (p._should_convert_to_nullable[i]) { + data_type = vectorized::make_nullable(data_type); + } + data_types.emplace_back(std::move(data_type)); + } + if (!try_get_hash_map_context_fixed( - *_shared_state->hash_table_variants, _build_expr_ctxs)) { + *_shared_state->hash_table_variants, data_types)) { _shared_state->hash_table_variants ->emplace(); } diff --git a/be/src/vec/common/hash_table/hash_map_context_creator.h b/be/src/vec/common/hash_table/hash_map_context_creator.h index 89d6ab865ad03a..fa27d1df181e56 100644 --- a/be/src/vec/common/hash_table/hash_map_context_creator.h +++ b/be/src/vec/common/hash_table/hash_map_context_creator.h @@ -55,14 +55,23 @@ void get_hash_map_context_fixed(Variant& variant, size_t size, bool has_nullable template