Skip to content

Commit

Permalink
fix array set with left param which is const column
Browse files Browse the repository at this point in the history
  • Loading branch information
amorynan committed Jun 27, 2024
1 parent f5c0585 commit 13c999f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion be/src/vec/functions/array/function_array_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ struct ArraySetImpl {
constexpr auto execute_left_column_first = Impl::Action::execute_left_column_first;
size_t current = 0;
Impl impl;
for (size_t row = 0; row < left_data.offsets_ptr->size(); ++row) {
size_t row_size = left_data.offsets_ptr->size();
if constexpr (LCONST) {
row_size = right_data.offsets_ptr->size();
}
for (size_t row = 0; row < row_size; ++row) {
size_t count = 0;
size_t left_off = (*left_data.offsets_ptr)[index_check_const(row, LCONST) - 1];
size_t left_len = (*left_data.offsets_ptr)[index_check_const(row, LCONST)] - left_off;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1659,14 +1659,26 @@
10005 [10005, null, null] [null, 3, 10005, 2, 1]
10006 [60002, 60002, 60003, null, 60005] [null, 3, 60002, 60005, 60003, 2, 1]

-- !select_union_left_const --
10005 [10005, null, null] [null, 3, 10005, 2, 1]
10006 [60002, 60002, 60003, null, 60005] [null, 3, 60002, 60005, 60003, 2, 1]

-- !select_except --
10005 [10005, null, null] [10005, null]
10006 [60002, 60002, 60003, null, 60005] [60002, 60003, null, 60005]

-- !select_except_left_const --
10005 [10005, null, null] [1, 2, 3]
10006 [60002, 60002, 60003, null, 60005] [1, 2, 3]

-- !select_intersect --
10005 [10005, null, null] [null]
10006 [60002, 60002, 60003, null, 60005] [null]

-- !select_intersect_left_const --
10005 [10005, null, null] [null]
10006 [60002, 60002, 60003, null, 60005] [null]

-- !select_array_datetimev2_1 --
1 ["2023-01-19 18:11:11.111", "2023-01-19 18:22:22.222", "2023-01-19 18:33:33.333"] ["2023-01-19 18:22:22.222", "2023-01-19 18:33:33.333", "2023-01-19 18:44:44.444"] ["2023-01-19 18:11:11.111111", "2023-01-19 18:22:22.222222", "2023-01-19 18:33:33.333333"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ suite("test_array_functions") {
sql """ insert into ${tableName3} values (10006,'bbbbb',[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_union_left_const "select class_id, student_ids, array_union([1,2,3], 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_except_left_const "select class_id, student_ids, array_except([1,2,3], student_ids) 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;"
qt_select_intersect_left_const "select class_id, student_ids, array_intersect([1,2,3,null], student_ids) from ${tableName3} order by class_id;"

def tableName4 = "tbl_test_array_datetimev2_functions"

Expand Down

0 comments on commit 13c999f

Please sign in to comment.