This is an automated email from the ASF dual-hosted git repository.
zhangstar333 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new e3ba7875bfb [cherry-pick](branch-30) fix array_map cause coredump as
NULL (#51618) (#51740)
e3ba7875bfb is described below
commit e3ba7875bfb50c3a6284037c88600f73cfbd8298
Author: zhangstar333 <[email protected]>
AuthorDate: Mon Jun 30 12:31:10 2025 +0800
[cherry-pick](branch-30) fix array_map cause coredump as NULL (#51618)
(#51740)
Problem Summary:
cherry-pick from https://github.com/apache/doris/pull/51618
---
.../exprs/lambda_function/varray_map_function.cpp | 34 +++++++++++++++-
.../array_functions/test_array_map_function.out | Bin 2522 -> 2588 bytes
.../array_functions/test_array_map_function.groovy | 44 ++++++++++++++++++++-
3 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exprs/lambda_function/varray_map_function.cpp
b/be/src/vec/exprs/lambda_function/varray_map_function.cpp
index 23050b6593c..5f90827a70c 100644
--- a/be/src/vec/exprs/lambda_function/varray_map_function.cpp
+++ b/be/src/vec/exprs/lambda_function/varray_map_function.cpp
@@ -192,6 +192,39 @@ public:
data_types.push_back(col_type.get_nested_type());
}
+ ColumnWithTypeAndName result_arr;
+ // if column_array is NULL, we know the array_data_column will not
write any data,
+ // so the column is empty. eg : (x) -> concat('|',x + "1"). if still
execute the lambda function, will cause the bolck rows are not equal
+ // the x column is empty, but "|" is const literal, size of column is
1, so the block rows is 1, but the x column is empty, will be coredump.
+ if (std::any_of(lambda_datas.begin(), lambda_datas.end(),
+ [](const auto& v) { return v->empty(); })) {
+ DataTypePtr nested_type;
+ bool is_nullable = result_type->is_nullable();
+ if (is_nullable) {
+ nested_type =
+ assert_cast<const
DataTypeNullable*>(result_type.get())->get_nested_type();
+ } else {
+ nested_type = result_type;
+ }
+ auto empty_nested_column = assert_cast<const
DataTypeArray*>(nested_type.get())
+ ->get_nested_type()
+ ->create_column();
+ auto result_array_column =
ColumnArray::create(std::move(empty_nested_column),
+
std::move(array_column_offset));
+
+ if (is_nullable) {
+ result_arr =
{ColumnNullable::create(std::move(result_array_column),
+
std::move(outside_null_map)),
+ result_type, "Result"};
+ } else {
+ result_arr = {std::move(result_array_column), result_type,
"Result"};
+ }
+
+ block->insert(result_arr);
+ *result_column_id = block->columns() - 1;
+ return Status::OK();
+ }
+
ColumnPtr result_col = nullptr;
DataTypePtr res_type;
std::string res_name;
@@ -260,7 +293,6 @@ public:
} while (args.current_row_idx < block->rows());
//4. get the result column after execution, reassemble it into a new
array column, and return.
- ColumnWithTypeAndName result_arr;
if (result_type->is_nullable()) {
if (res_type->is_nullable()) {
result_arr = {
diff --git
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_map_function.out
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_map_function.out
index 211092f3875..0e3935d131f 100644
Binary files
a/regression-test/data/query_p0/sql_functions/array_functions/test_array_map_function.out
and
b/regression-test/data/query_p0/sql_functions/array_functions/test_array_map_function.out
differ
diff --git
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_map_function.groovy
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_map_function.groovy
index acf6dba0600..fb67352a0d4 100644
---
a/regression-test/suites/query_p0/sql_functions/array_functions/test_array_map_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/array_functions/test_array_map_function.groovy
@@ -103,8 +103,8 @@ suite("test_array_map_function") {
}
sql "DROP TABLE IF EXISTS ${tableName}"
+ sql "DROP TABLE IF EXISTS array_map_test"
-sql "DROP TABLE IF EXISTS array_map_test"
sql """ CREATE TABLE IF NOT EXISTS array_map_test (
id INT,
int_array ARRAY<INT>,
@@ -129,4 +129,46 @@ sql "DROP TABLE IF EXISTS array_map_test"
qt_select_25 """
SELECT id, array_map(x -> array_map(y -> y * 10, x), nested_array)
FROM array_map_test order by id;
"""
+
+ sql "DROP TABLE IF EXISTS db"
+
+ sql """ CREATE TABLE `db` (
+ `id` VARCHAR(255) NULL COMMENT '主键',
+ `QC_result_list` ARRAY<TEXT> NULL COMMENT '标签预刷'
+ ) ENGINE=OLAP
+ UNIQUE KEY(`id`)
+ DISTRIBUTED BY HASH(`id`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "is_being_synced" = "false",
+ "storage_medium" = "hdd",
+ "storage_format" = "V2",
+ "enable_unique_key_merge_on_write" = "true",
+ "light_schema_change" = "true",
+ "disable_auto_compaction" = "false",
+ "enable_single_replica_compaction" = "false"
+ );
+ """
+
+ sql """insert into db values(1,null);
+ """
+
+ qt_select_26 """
+ select array_map(
+ (x, y, z) -> concat(
+ '|',
+ x + "1",
+ '|',
+ x + "2",
+ '|',
+ x + "3"
+ ),
+ QC_result_list,
+ QC_result_list,
+ QC_result_list
+ ) FROM db;
+ """
+
+ qt_select_27 """ select QC_result_list, array_map( x
-> concat( '|', x + "1"
), QC_result_list ) FROM db; """
+ qt_select_28 """ select array_map((x,y)->x,[],[]); """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]