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

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


The following commit(s) were added to refs/heads/master by this push:
     new 16d8a1853a [Bug](array-function) array set function not handle all 
null value (#14318)
16d8a1853a is described below

commit 16d8a1853a7bb02217e97c39d7936ca70ed04c27
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Tue Nov 22 09:07:43 2022 +0800

    [Bug](array-function) array set function not handle all null value (#14318)
---
 .../vec/functions/array/function_array_except.cpp  |  2 ++
 .../functions/array/function_array_intersect.cpp   |  5 +++++
 be/src/vec/functions/array/function_array_set.h    |  4 ++--
 .../vec/functions/array/function_array_union.cpp   |  2 ++
 .../array_functions/test_array_functions.out       | 16 +++++++++++++--
 .../array_functions/test_array_functions.groovy    | 23 ++++++++++++++++++++++
 6 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/be/src/vec/functions/array/function_array_except.cpp 
b/be/src/vec/functions/array/function_array_except.cpp
index 574eeb3eba..93894b0e47 100644
--- a/be/src/vec/functions/array/function_array_except.cpp
+++ b/be/src/vec/functions/array/function_array_except.cpp
@@ -67,6 +67,8 @@ struct ExceptAction {
         }
         return false;
     }
+
+    void reset() { null_flag = false; }
 };
 
 using FunctionArrayExcept =
diff --git a/be/src/vec/functions/array/function_array_intersect.cpp 
b/be/src/vec/functions/array/function_array_intersect.cpp
index c80041a599..cf726fce6b 100644
--- a/be/src/vec/functions/array/function_array_intersect.cpp
+++ b/be/src/vec/functions/array/function_array_intersect.cpp
@@ -67,6 +67,11 @@ struct IntersectAction {
         }
         return false;
     }
+
+    void reset() {
+        null_flag = false;
+        result_null_flag = false;
+    }
 };
 
 using FunctionArrayIntersect =
diff --git a/be/src/vec/functions/array/function_array_set.h 
b/be/src/vec/functions/array/function_array_set.h
index e412a9107e..df311131df 100644
--- a/be/src/vec/functions/array/function_array_set.h
+++ b/be/src/vec/functions/array/function_array_set.h
@@ -21,9 +21,7 @@
 #include "vec/columns/column_string.h"
 #include "vec/common/hash_table/hash_set.h"
 #include "vec/data_types/data_type_array.h"
-#include "vec/data_types/data_type_number.h"
 #include "vec/functions/array/function_array_utils.h"
-#include "vec/functions/function.h"
 #include "vec/functions/function_helpers.h"
 
 namespace doris::vectorized {
@@ -69,6 +67,7 @@ struct OpenSetImpl {
     void reset() {
         set.clear();
         result_set.clear();
+        action.reset();
     }
     template <bool is_left>
     void apply(const ColumnArrayExecutionData& src, size_t off, size_t len,
@@ -105,6 +104,7 @@ struct OpenSetImpl<operation, ColumnString> {
     void reset() {
         set.clear();
         result_set.clear();
+        action.reset();
     }
     template <bool is_left>
     void apply(const ColumnArrayExecutionData& src, size_t off, size_t len,
diff --git a/be/src/vec/functions/array/function_array_union.cpp 
b/be/src/vec/functions/array/function_array_union.cpp
index bee201a843..990f621435 100644
--- a/be/src/vec/functions/array/function_array_union.cpp
+++ b/be/src/vec/functions/array/function_array_union.cpp
@@ -55,6 +55,8 @@ struct UnionAction {
         }
         return false;
     }
+
+    void reset() { null_flag = false; }
 };
 
 using FunctionArrayUnion = 
FunctionArrayBinary<ArraySetImpl<SetOperation::UNION>, NameArrayUnion>;
diff --git 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
index d7f366c0c8..ca05289e6b 100644
--- 
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
+++ 
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_functions.out
@@ -73,7 +73,7 @@
 5      \N
 6      \N
 7      \N
-8      [1, 2, 3, 4]
+8      [1, 2, 3, 4, NULL]
 9      [1, 2, 3]
 
 -- !select --
@@ -84,7 +84,7 @@
 5      \N
 6      \N
 7      \N
-8      [4]
+8      [4, NULL]
 9      [3]
 
 -- !select --
@@ -456,3 +456,15 @@
 [1, 2, 3, 3, 4, 4, NULL]       \N
 [1, 2, 3]      1,2,3,4,8,9
 
+-- !select_union --
+10005  [10005, NULL, NULL]     [10005, NULL, 1, 2, 3]
+10006  [60002, 60002, 60003, NULL, 60005]      [60002, 60003, NULL, 60005, 1, 
2, 3]
+
+-- !select_except --
+10005  [10005, NULL, NULL]     [10005, NULL]
+10006  [60002, 60002, 60003, NULL, 60005]      [60002, 60003, NULL, 60005]
+
+-- !select_intersect --
+10005  [10005, NULL, NULL]     [NULL]
+10006  [60002, 60002, 60003, NULL, 60005]      [NULL]
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
index 223997ed40..9f29b2c2fd 100644
--- 
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_functions.groovy
@@ -119,4 +119,27 @@ suite("test_array_functions") {
 
     qt_select "select k2, bitmap_to_string(bitmap_from_array(k2)) from 
${tableName} order by k1;"
     
+    def tableName3 = "tbl_test_array_set"
+    sql """DROP TABLE IF EXISTS ${tableName3}"""
+    sql """
+            create table IF NOT EXISTS ${tableName3}(
+                  class_id int ,
+                  class_name varchar(20),
+                  student_ids array<int>
+                  ) ENGINE=OLAP
+                  DUPLICATE KEY(`class_id`,class_name)
+                  COMMENT "OLAP"
+                  DISTRIBUTED BY HASH(`class_name`) BUCKETS 2
+                  PROPERTIES (
+                  "replication_allocation" = "tag.location.default: 1",
+                  "in_memory" = "false",
+                  "storage_format" = "V2"
+                  );
+        """
+    sql """ insert into ${tableName3} values (10005,'四年级三班',[10005,null,null]) 
"""
+    sql """ insert into ${tableName3} values 
(10006,'六年级一班',[60002,60002,60003,null,60005]) """
+    
+    qt_select_union "select class_id, student_ids, 
array_union(student_ids,[1,2,3]) from ${tableName3} order by class_id;"
+    qt_select_except "select class_id, student_ids, 
array_except(student_ids,[1,2,3]) from ${tableName3} order by class_id;"
+    qt_select_intersect "select class_id, student_ids, 
array_intersect(student_ids,[1,2,3,null]) from ${tableName3} order by class_id;"
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to