From f40f2e12bfd5ae0bc4543d430951a233ddf76aa6 Mon Sep 17 00:00:00 2001 From: BiteTheDDDDt Date: Tue, 18 Feb 2025 11:51:19 +0800 Subject: [PATCH] fix find null get wrong result on set operators --- be/src/vec/common/columns_hashing.h | 8 ++++-- .../query_p0/operator/test_set_operator.out | 2 ++ .../operator/test_set_operator.groovy | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/be/src/vec/common/columns_hashing.h b/be/src/vec/common/columns_hashing.h index f0a365cfc09f37..60c2370bc6086a 100644 --- a/be/src/vec/common/columns_hashing.h +++ b/be/src/vec/common/columns_hashing.h @@ -152,8 +152,12 @@ struct HashMethodSingleLowNullableColumn : public SingleColumnMethod { 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}; + if (key_column->is_null_at(i)) { + if (data.has_null_key_data()) { + return FindResult {&data.template get_null_key_data(), true}; + } else { + return FindResult {nullptr, false}; + } } return Base::find_key_impl(key, hash_value, data); } diff --git a/regression-test/data/query_p0/operator/test_set_operator.out b/regression-test/data/query_p0/operator/test_set_operator.out index 48eb4a0c9bac40..211854115bca65 100644 --- a/regression-test/data/query_p0/operator/test_set_operator.out +++ b/regression-test/data/query_p0/operator/test_set_operator.out @@ -25,3 +25,5 @@ 5 5 7 7 +-- !test -- + diff --git a/regression-test/suites/query_p0/operator/test_set_operator.groovy b/regression-test/suites/query_p0/operator/test_set_operator.groovy index 7d6219585e4c4c..a013313b254e3a 100644 --- a/regression-test/suites/query_p0/operator/test_set_operator.groovy +++ b/regression-test/suites/query_p0/operator/test_set_operator.groovy @@ -97,4 +97,31 @@ suite("test_set_operators", "query,p0,arrow_flight_sql") { order_qt_select_except """ select col1, col1 from t1 except select col1, col1 from t2; """ + + sql """ + DROP TABLE IF EXISTS a_table; + """ + sql """ + create table a_table ( + k1 int null + ) + duplicate key (k1) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1"); + """ + sql """ + DROP TABLE IF EXISTS b_table; + """ + sql """ + create table b_table ( + k1 int null + ) + duplicate key (k1) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1"); + """ + + sql "insert into a_table select 0;" + sql "insert into b_table select null;" + qt_test "select * from a_table intersect select * from b_table;" }