branch-2.1: [Bug](set) fix find null get wrong result on set operators #48001 (#48020)

Cherry-picked from #48001

Co-authored-by: Pxl <xl@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-02-19 09:26:49 +08:00
committed by GitHub
parent c099ccdbd0
commit c7ad5b6904
3 changed files with 35 additions and 2 deletions

View File

@ -139,8 +139,12 @@ struct HashMethodSingleLowNullableColumn : public SingleColumnMethod {
template <typename Data, typename Key>
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<Mapped>(), true};
if (key_column->is_null_at(i)) {
if (data.has_null_key_data()) {
return FindResult {&data.template get_null_key_data<Mapped>(), true};
} else {
return FindResult {nullptr, false};
}
}
return Base::find_key_impl(key, hash_value, data);
}

View File

@ -25,3 +25,5 @@
5 5
7 7
-- !test --

View File

@ -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;"
}