diff --git a/be/src/vec/common/columns_hashing.h b/be/src/vec/common/columns_hashing.h index 83f01fdf4b2fc1..c25c8acdb7b64c 100644 --- a/be/src/vec/common/columns_hashing.h +++ b/be/src/vec/common/columns_hashing.h @@ -136,6 +136,14 @@ struct HashMethodSingleLowNullableColumn : public SingleColumnMethod { data.lazy_emplace(std::forward(key), it, hash_value, std::forward(f)); return *lookup_result_get_mapped(it); } + + template + ALWAYS_INLINE FindResult find_key_with_hash(Data& data, size_t i, Key key, size_t hash_value) { + if (key_column->is_null_at(i) && data.has_null_key_data()) { + return FindResult {&data.template get_null_key_data(), true}; + } + return Base::find_key_impl(key, hash_value, data); + } }; } // namespace ColumnsHashing diff --git a/be/src/vec/common/columns_hashing_impl.h b/be/src/vec/common/columns_hashing_impl.h index d0ef8a4b014c96..6d8ba4395102e7 100644 --- a/be/src/vec/common/columns_hashing_impl.h +++ b/be/src/vec/common/columns_hashing_impl.h @@ -89,7 +89,7 @@ class HashMethodBase { } template - ALWAYS_INLINE FindResult find_key_with_hash(Data& data, size_t hash_value, Key key) { + ALWAYS_INLINE FindResult find_key_with_hash(Data& data, size_t i, Key key, size_t hash_value) { return find_key_impl(key, hash_value, data); } diff --git a/be/src/vec/common/hash_table/hash_map_context.h b/be/src/vec/common/hash_table/hash_map_context.h index e607eba6c18616..d4b41dc26e0e70 100644 --- a/be/src/vec/common/hash_table/hash_map_context.h +++ b/be/src/vec/common/hash_table/hash_map_context.h @@ -125,7 +125,7 @@ struct MethodBaseInner { if constexpr (!is_string_hash_map()) { prefetch(i); } - return state.find_key_with_hash(*hash_table, hash_values[i], keys[i]); + return state.find_key_with_hash(*hash_table, i, keys[i], hash_values[i]); } template diff --git a/regression-test/data/query_p0/aggregate/aggregate.out b/regression-test/data/query_p0/aggregate/aggregate.out index 9f9870797a0b03..ffd3790499423f 100644 --- a/regression-test/data/query_p0/aggregate/aggregate.out +++ b/regression-test/data/query_p0/aggregate/aggregate.out @@ -695,3 +695,5 @@ TESTING AGAIN -- !subquery_without_inner_predicate -- 7 +-- !aggregate_limit_contain_null -- +16 \N diff --git a/regression-test/suites/query_p0/aggregate/aggregate.groovy b/regression-test/suites/query_p0/aggregate/aggregate.groovy index 1b0987538cc0b2..b611ff92b0eaba 100644 --- a/regression-test/suites/query_p0/aggregate/aggregate.groovy +++ b/regression-test/suites/query_p0/aggregate/aggregate.groovy @@ -304,4 +304,8 @@ suite("aggregate") { qt_subquery_without_inner_predicate """ select count(*) from (select t2.c_bigint, t2.c_double, t2.c_string from (select c_bigint, c_double, c_string, c_date,c_timestamp, c_short_decimal from regression_test_query_p0_aggregate.${tableName} where c_bigint > 5000) t2)t1 """ + + qt_aggregate_limit_contain_null """ + select count(), cast(k12 as int) as t from baseall group by t limit 1; + """ }