Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions be/src/vec/exprs/lambda_function/varray_map_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ArrayMapFunction : public LambdaFunction {
Block lambda_block;
auto column_size = names.size();
MutableColumns columns(column_size);
while (args_info.current_row_idx < block->rows()) {
do {
bool mem_reuse = lambda_block.mem_reuse();
for (int i = 0; i < column_size; i++) {
if (mem_reuse) {
Expand All @@ -222,7 +222,7 @@ class ArrayMapFunction : public LambdaFunction {
long current_step = std::min(
max_step, (long)(args_info.cur_size - args_info.current_offset_in_array));
size_t pos = args_info.array_start + args_info.current_offset_in_array;
for (int i = 0; i < arguments.size(); ++i) {
for (int i = 0; i < arguments.size() && current_step > 0; ++i) {
columns[gap + i]->insert_range_from(*lambda_datas[i], pos, current_step);
}
args_info.current_offset_in_array += current_step;
Expand Down Expand Up @@ -265,7 +265,7 @@ class ArrayMapFunction : public LambdaFunction {
}
result_col->insert_range_from(*res_col, 0, res_col->size());
lambda_block.clear_column_data(column_size);
}
} while (args_info.current_row_idx < block->rows());

//4. get the result column after execution, reassemble it into a new array column, and return.
ColumnWithTypeAndName result_arr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,10 @@
1 [1, 2, 3, 4, 5] [10, 20, -40, 80, -100]
2 [6, 7, 8] [10, 12, 13]

-- !select_25 --
1 [[10, 20], [30, 40]]
2 [[50, 60], [70, 80]]
3 []
4 [[90, 100], [110, 120]]
5 [[130]]

Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@ suite("test_array_map_function") {
}

sql "DROP TABLE IF EXISTS ${tableName}"

sql """ CREATE TABLE IF NOT EXISTS array_map_test (
id INT,
int_array ARRAY<INT>,
string_array ARRAY<STRING>,
double_array ARRAY<DOUBLE>,
nested_array ARRAY<ARRAY<INT>>,
nullable_array ARRAY<INT> NULL
) ENGINE=OLAP
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 10
PROPERTIES (
"replication_num" = "1"
);
"""
sql """ INSERT INTO array_map_test VALUES
(1, [1,2,3], ['a','b','c'], [1.1,2.2,3.3], [[1,2],[3,4]], NULL),
(2, [10,20], ['x','y'], [10.5,20.5], [[5,6],[7,8]], [1,2,3]),
(3, [], [], [], [], []),
(4, [100,200,300], ['one','two','three'], [100.1,200.2,300.3], [[9,10],[11,12]], [4,5,6]),
(5, [5], ['single'], [5.5], [[13]], [7]);
"""
qt_select_25 """
SELECT id, array_map(x -> array_map(y -> y * 10, x), nested_array) FROM array_map_test order by id;
"""
}
Loading