[fix](array)fix array_except/union for left const return only one row result #36776 (#36986)

This commit is contained in:
amory
2024-06-30 12:25:17 +08:00
committed by GitHub
parent 021ed1d690
commit d237a4d303
3 changed files with 20 additions and 1 deletions

View File

@ -181,7 +181,11 @@ private:
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;

View File

@ -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"]

View File

@ -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"