This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 60ca71e9cf4 branch-4.1: [fix](be) Fix concat_ws nullable array
handling #64703 (#64725)
60ca71e9cf4 is described below
commit 60ca71e9cf4f77cbafdd98c712081a40610182bd
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jun 23 19:44:10 2026 +0800
branch-4.1: [fix](be) Fix concat_ws nullable array handling #64703 (#64725)
Cherry-picked from #64703
Co-authored-by: HappenLee <[email protected]>
---
be/src/exprs/function/function_string_concat.h | 12 ++++++++++++
.../nereids_function_p0/scalar_function/concat_ws.out | 7 +++++++
.../nereids_function_p0/scalar_function/concat_ws.groovy | 15 ++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/be/src/exprs/function/function_string_concat.h
b/be/src/exprs/function/function_string_concat.h
index cc3784674af..153a508909c 100644
--- a/be/src/exprs/function/function_string_concat.h
+++ b/be/src/exprs/function/function_string_concat.h
@@ -417,6 +417,11 @@ public:
std::vector<std::string_view> views;
if (is_column<ColumnArray>(argument_columns[1].get())) {
+ if (argument_size != 2) {
+ return Status::InvalidArgument(
+ "concat_ws with array argument expects exactly 2
arguments, but got {}",
+ argument_size);
+ }
// Determine if the nested type of the array is String
const auto& array_column = reinterpret_cast<const
ColumnArray&>(*argument_columns[1]);
if (!array_column.get_data().is_column_string()) {
@@ -472,6 +477,7 @@ private:
const auto& src_string_offsets = string_column.get_offsets();
const auto& src_array_offsets = array_column.get_offsets();
size_t current_src_array_offset = 0;
+ auto& array_nullmap = *null_list[1];
// Concat string in array
for (size_t i = 0; i < input_rows_count; ++i) {
@@ -485,6 +491,12 @@ private:
continue;
}
+ if (array_nullmap[i]) {
+ StringOP::push_empty_string(i, res_data, res_offset);
+ current_src_array_offset += src_array_offsets[i] -
src_array_offsets[i - 1];
+ continue;
+ }
+
int sep_size = sep_offsets[i] - sep_offsets[i - 1];
const char* sep_data = reinterpret_cast<const
char*>(&sep_chars[sep_offsets[i - 1]]);
diff --git
a/regression-test/data/nereids_function_p0/scalar_function/concat_ws.out
b/regression-test/data/nereids_function_p0/scalar_function/concat_ws.out
index 20493bb95c9..f4768319fe6 100644
--- a/regression-test/data/nereids_function_p0/scalar_function/concat_ws.out
+++ b/regression-test/data/nereids_function_p0/scalar_function/concat_ws.out
@@ -37,3 +37,10 @@ a-b-css-d
x-y-z
你好-世界-Doris-Nereids
+-- !concat_ws_array_null_full --
+1 [] 0
+2 [a,b,c] 5
+
+-- !concat_ws_array_null_filter --
+1 [] 0
+
diff --git
a/regression-test/suites/nereids_function_p0/scalar_function/concat_ws.groovy
b/regression-test/suites/nereids_function_p0/scalar_function/concat_ws.groovy
index 44808aa999f..0517e09e7be 100644
---
a/regression-test/suites/nereids_function_p0/scalar_function/concat_ws.groovy
+++
b/regression-test/suites/nereids_function_p0/scalar_function/concat_ws.groovy
@@ -39,4 +39,17 @@ suite("nereids_scalar_fn_concat_ws") {
sql "INSERT INTO test_concat_ws_1 VALUES (1, ['a','b'], ['css',null,'d']),
(2, ['x',null], ['y','z']),(3,['你好','世界'],['Doris',null,'Nereids'])"
qt_concat_ws_insert_1 "SELECT concat_ws('-', a, b) FROM test_concat_ws_1
ORDER BY id"
-}
\ No newline at end of file
+ sql "DROP TABLE IF EXISTS test_concat_ws_array_null"
+ sql "CREATE TABLE test_concat_ws_array_null (id INT, a ARRAY<VARCHAR>, b
ARRAY<VARCHAR>, c ARRAY<VARCHAR>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES ('replication_num' = '1')"
+ sql "INSERT INTO test_concat_ws_array_null VALUES (1, ['a'], NULL, ['b']),
(2, ['a'], ['b'], ['c'])"
+ qt_concat_ws_array_null_full "SELECT id, CONCAT('[', CONCAT_WS(',', a, b,
c), ']'), LENGTH(CONCAT_WS(',', a, b, c)) FROM test_concat_ws_array_null ORDER
BY id"
+ qt_concat_ws_array_null_filter "SELECT id, CONCAT('[', CONCAT_WS(',', a,
b, c), ']'), LENGTH(CONCAT_WS(',', a, b, c)) FROM test_concat_ws_array_null
WHERE id = 1"
+
+ sql "SET disable_nereids_expression_rules = 'CONCATWS_MULTI_ARRAY_TO_ONE'"
+ test {
+ sql "SELECT CONCAT_WS(',', a, b, c) FROM test_concat_ws_array_null
ORDER BY id"
+ exception "concat_ws with array argument expects exactly 2 arguments"
+ }
+ sql "SET disable_nereids_expression_rules = ''"
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]