This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 42808a02dcc [Fix](func) fix group_array_intersect result error in all 
arr contain null (#46590)
42808a02dcc is described below

commit 42808a02dcc906fedb7dad6ee6aeb2b83b7ffb4c
Author: HappenLee <[email protected]>
AuthorDate: Fri Jan 10 20:14:23 2025 +0800

    [Fix](func) fix group_array_intersect result error in all arr contain null 
(#46590)
---
 be/src/exprs/hybrid_set.h                                     |  1 +
 .../aggregate_function_group_array_intersect.h                | 11 ++++-------
 .../data/query_p0/aggregate/group_array_intersect.out         |  3 +++
 .../suites/query_p0/aggregate/group_array_intersect.groovy    |  2 ++
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/be/src/exprs/hybrid_set.h b/be/src/exprs/hybrid_set.h
index 9599a60e299..b9049c05ca3 100644
--- a/be/src/exprs/hybrid_set.h
+++ b/be/src/exprs/hybrid_set.h
@@ -215,6 +215,7 @@ public:
         _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
diff --git 
a/be/src/vec/aggregate_functions/aggregate_function_group_array_intersect.h 
b/be/src/vec/aggregate_functions/aggregate_function_group_array_intersect.h
index f37645bca77..075909534af 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_group_array_intersect.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_group_array_intersect.h
@@ -122,7 +122,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) {
@@ -210,10 +210,7 @@ public:
                 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>();
@@ -414,7 +411,7 @@ public:
                 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) {
@@ -447,7 +444,7 @@ public:
                 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();
diff --git a/regression-test/data/query_p0/aggregate/group_array_intersect.out 
b/regression-test/data/query_p0/aggregate/group_array_intersect.out
index e9e0efec5dc..dbbd70b6c9a 100644
--- a/regression-test/data/query_p0/aggregate/group_array_intersect.out
+++ b/regression-test/data/query_p0/aggregate/group_array_intersect.out
@@ -91,3 +91,6 @@
 -- !notnull_6 --
 []
 
+-- !notnull_7 --
+[]
+
diff --git 
a/regression-test/suites/query_p0/aggregate/group_array_intersect.groovy 
b/regression-test/suites/query_p0/aggregate/group_array_intersect.groovy
index a802d42a66a..647225eb8f1 100644
--- a/regression-test/suites/query_p0/aggregate/group_array_intersect.groovy
+++ b/regression-test/suites/query_p0/aggregate/group_array_intersect.groovy
@@ -103,4 +103,6 @@ suite("group_array_intersect") {
     qt_notnull_4 """select group_array_intersect(c_array_string) from 
group_array_intersect_test_not_null where id between 1 and 2;"""
     qt_notnull_5 """select group_array_intersect(c_array_int), 
group_array_intersect(c_array_float), group_array_intersect(c_array_string) 
from group_array_intersect_test_not_null where id between 3 and 4;"""
     qt_notnull_6 """select 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;"""
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to