Skip to content

Commit

Permalink
branch-3.0: [Fix](func) fix group_array_intersect result error in all…
Browse files Browse the repository at this point in the history
… arr contain null apache#46521 (apache#46578)

Cherry-picked from apache#46521

Co-authored-by: HappenLee <[email protected]>
  • Loading branch information
github-actions[bot] and HappenLee authored Jan 10, 2025
1 parent f3e570a commit 0d4b777
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions be/src/exprs/hybrid_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class HybridSetBase : public RuntimeFilterFuncBase {
_contains_null |= set->_contains_null;
}

bool empty() { return !_contains_null && size() == 0; }
virtual int size() = 0;
virtual bool find(const void* data) const = 0;
// use in vectorize execute engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct AggregateFunctionGroupArrayIntersectData {
set->insert(src_data);
}
init = true;
} else if (set->size() != 0 || set->contain_null()) {
} else if (!set->empty()) {
Set new_set = std::make_unique<NullableNumericOrDateSetType>();

for (size_t i = 0; i < arr_size; ++i) {
Expand Down Expand Up @@ -213,10 +213,7 @@ class AggregateFunctionGroupArrayIntersect
it->next();
}
init = true;
return;
}

if (set->size() != 0) {
} else if (!set->empty()) {
auto create_new_set = [](auto& lhs_val, auto& rhs_val) {
typename State::Set new_set =
std::make_unique<typename State::NullableNumericOrDateSetType>();
Expand Down Expand Up @@ -419,7 +416,7 @@ class AggregateFunctionGroupArrayIntersectGeneric
set->insert((void*)src.data, src.size);
}
init = true;
} else if (set->size() != 0 || set->contain_null()) {
} else if (!set->empty()) {
typename State::Set new_set = std::make_unique<NullableStringSet>();

for (size_t i = 0; i < arr_size; ++i) {
Expand Down Expand Up @@ -452,7 +449,7 @@ class AggregateFunctionGroupArrayIntersectGeneric
it->next();
}
init = true;
} else if (set->size() != 0) {
} else if (!set->empty()) {
auto create_new_set = [](auto& lhs_val, auto& rhs_val) {
typename State::Set new_set = std::make_unique<NullableStringSet>();
HybridSetBase::IteratorBase* it = lhs_val->begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@
-- !notnull_6 --
[]

-- !notnull_7 --
[]

Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ suite("group_array_intersect") {
qt_notnull_4 """select array_sort(group_array_intersect(c_array_string)) from group_array_intersect_test_not_null where id between 1 and 2;"""
qt_notnull_5 """select array_sort(group_array_intersect(c_array_int)), array_sort(group_array_intersect(c_array_float)), array_sort(group_array_intersect(c_array_string)) from group_array_intersect_test_not_null where id between 3 and 4;"""
qt_notnull_6 """select array_sort(group_array_intersect(c_array_string)) from group_array_intersect_test_not_null where id between 1 and 5;"""
qt_notnull_7 """select array_sort(group_array_intersect(c_array_float)) from group_array_intersect_test_not_null where id between 1 and 5;"""
}

0 comments on commit 0d4b777

Please sign in to comment.