Skip to content

Commit

Permalink
[test](case) Some array-related cases are missing array sort. (apache…
Browse files Browse the repository at this point in the history
…#48133)

### What problem does this PR solve?
1. Some aggregate functions, such as array_union, require array sort to
ensure order in the output.
2. For the foreach function, if the input is an array, it is difficult
to guarantee the order of the output. Therefore, some unstable cases
have been removed, leaving only those related to scalars.

Problem Summary:

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [x] Regression test
    - [ ] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

- Behavior changed:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
  • Loading branch information
Mryange authored Feb 20, 2025
1 parent e17a96b commit 0a6f7f6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 110 deletions.
21 changes: 0 additions & 21 deletions regression-test/data/function_p0/test_agg_foreach.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,3 @@
-- !sql --
["{"num_buckets":3,"buckets":[{"lower":"1","upper":"1","ndv":1,"count":1,"pre_sum":0},{"lower":"20","upper":"20","ndv":1,"count":1,"pre_sum":1},{"lower":"100","upper":"100","ndv":1,"count":1,"pre_sum":2}]}", "{"num_buckets":1,"buckets":[{"lower":"2","upper":"2","ndv":1,"count":2,"pre_sum":0}]}", "{"num_buckets":1,"buckets":[{"lower":"3","upper":"3","ndv":1,"count":1,"pre_sum":0}]}"]

-- !sql --
[0, 2, 3] [117, 2, 3] [113, 0, 3]

-- !sql --
["ab,cd,efg", "123,c", "114514"] ["ababcdabefg", "123123c", "114514"]

-- !sql --
[[1], [1], [1]] [[1, 1], [1, 1], [1, 1]] [[1, 1, 1], [1, 1, 1], [1, 1, 1]] [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]

-- !sql --
["ab", "123", "114514"] [1, 2, 3]

-- !sql --
[[20, 1, 100], [2], [3]] [["cd", "efg", "ab"], ["123", "c"], ["114514"]] [[1], [2], [3]]

-- !sql --
[[1, 20, 100], [2, 2], [3]] [["ab", "cd", "efg"], ["123", "c"], ["114514"]] [[1], [2, 2], [3]]

-- !sql --
[{1:1, 20:20, 100:100}, {2:2}, {3:3}] [{1:"ab", 20:"cd", 100:"efg"}, {2:"123"}, {3:"114514"}] [{"ab":"ab", "cd":"cd", "efg":"efg"}, {"123":"123", "c":"c"}, {"114514":"114514"}]

21 changes: 0 additions & 21 deletions regression-test/data/function_p0/test_agg_foreach_notnull.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,3 @@
-- !sql --
["{"num_buckets":3,"buckets":[{"lower":"1","upper":"1","ndv":1,"count":1,"pre_sum":0},{"lower":"20","upper":"20","ndv":1,"count":1,"pre_sum":1},{"lower":"100","upper":"100","ndv":1,"count":1,"pre_sum":2}]}", "{"num_buckets":1,"buckets":[{"lower":"2","upper":"2","ndv":1,"count":2,"pre_sum":0}]}", "{"num_buckets":1,"buckets":[{"lower":"3","upper":"3","ndv":1,"count":1,"pre_sum":0}]}"]

-- !sql --
[0, 2, 3] [117, 2, 3] [113, 0, 3]

-- !sql --
["ab,cd,efg", "123,c", "114514"] ["ababcdabefg", "123123c", "114514"]

-- !sql --
[[1], [1], [1]] [[1, 1], [1, 1], [1, 1]] [[1, 1, 1], [1, 1, 1], [1, 1, 1]] [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]

-- !sql --
["ab", "123", "114514"] [1, 2, 3]

-- !sql --
[[20, 1, 100], [2], [3]] [["cd", "efg", "ab"], ["123", "c"], ["114514"]] [[1], [2], [3]]

-- !sql --
[[1, 20, 100], [2, 2], [3]] [["ab", "cd", "efg"], ["123", "c"], ["114514"]] [[1], [2, 2], [3]]

-- !sql --
[{1:1, 20:20, 100:100}, {2:2}, {3:3}] [{1:"ab", 20:"cd", 100:"efg"}, {2:"123"}, {3:"114514"}] [{"ab":"ab", "cd":"cd", "efg":"efg"}, {"123":"123", "c":"c"}, {"114514":"114514"}]

Original file line number Diff line number Diff line change
Expand Up @@ -1656,16 +1656,16 @@
[1, 2, 3] 1,2,3

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

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

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

-- !select_except_left_const --
10005 [10005, null, null] [1, 2, 3]
Expand Down
28 changes: 0 additions & 28 deletions regression-test/suites/function_p0/test_agg_foreach.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,4 @@ suite("test_agg_foreach") {
} catch (Exception ex) {
assert("${ex}".contains("Unsupport the func"))
}

qt_sql """
select GROUP_BIT_AND_foreach(a), GROUP_BIT_OR_foreach(a), GROUP_BIT_XOR_foreach(a) from foreach_table;
"""

qt_sql """
select GROUP_CONCAT_foreach(s), GROUP_CONCAT_foreach(s,s) from foreach_table;
"""

qt_sql """
select retention_foreach(a), retention_foreach(a,a ),retention_foreach(a,a,a) , retention_foreach(a,a,a ,a) from foreach_table;
"""

qt_sql """
select any_value_foreach(s), any_value_foreach(a) from foreach_table;
"""

qt_sql """
select collect_set_foreach(a), collect_set_foreach(s) , collect_set_foreach(a,a) from foreach_table;
"""

qt_sql """
select collect_list_foreach(a), collect_list_foreach(s) , collect_list_foreach(a,a) from foreach_table;
"""

qt_sql """
select map_agg_foreach(a,a), map_agg_foreach(a,s) , map_agg_foreach(s,s) from foreach_table;
"""
}
28 changes: 0 additions & 28 deletions regression-test/suites/function_p0/test_agg_foreach_notnull.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,4 @@ suite("test_agg_foreach_not_null") {
} catch (Exception ex) {
assert("${ex}".contains("Unsupport the func"))
}

qt_sql """
select GROUP_BIT_AND_foreach(a), GROUP_BIT_OR_foreach(a), GROUP_BIT_XOR_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select GROUP_CONCAT_foreach(s), GROUP_CONCAT_foreach(s,s) from foreach_table_not_null;
"""

qt_sql """
select retention_foreach(a), retention_foreach(a,a ),retention_foreach(a,a,a) , retention_foreach(a,a,a ,a) from foreach_table_not_null;
"""

qt_sql """
select any_value_foreach(s), any_value_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select collect_set_foreach(a), collect_set_foreach(s) , collect_set_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select collect_list_foreach(a), collect_list_foreach(s) , collect_list_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select map_agg_foreach(a,a), map_agg_foreach(a,s) , map_agg_foreach(s,s) from foreach_table_not_null;
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ suite("test_array_functions") {
sql """ insert into ${tableName3} values (10005,'aaaaa',[10005,null,null]) """
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;"
qt_select_union "select class_id, student_ids, array_sort(array_union(student_ids,[1,2,3])) from ${tableName3} order by class_id;"
qt_select_union_left_const "select class_id, student_ids, array_sort(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_sort(array_except(student_ids,[1,2,3])) from ${tableName3} order by class_id;"
qt_select_except_left_const "select class_id, student_ids, array_sort(array_except([1,2,3], student_ids)) from ${tableName3} order by class_id;"
qt_select_intersect "select class_id, student_ids, array_sort(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_sort(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 0a6f7f6

Please sign in to comment.