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