Skip to content

Commit 9873357

Browse files
authored
chore: breakdown array.slt into smaller files (#21658)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #21645 . ## Rationale for this change ### Summary - Split the monolithic `array.slt` (10,038 lines) into 31 focused per-function test files under `test_files/array/` - Shared table setup (692 lines) extracted into `array/init_data.slt.part`, shared cleanup into `array/cleanup.slt.part`, each test file includes both via `include` directives - Removed `array.slt` from `TEST_PRIORITY_ENTRIES` in `test_file.rs` since split files are small enough to not need scheduling priority #### New files | File | Function(s) tested | |---|---| | `init_data.slt.part` | Shared table setup (included by all test files) | | `cleanup.slt.part` | Shared table teardown (included by all test files) | | `array_literal.slt` | Array literal syntax, coercion | | `array_index.slt` | `array[i]`, `array[i:j]`, `array[i:j:k]` | | `make_array.slt` | `make_array` / `make_list` | | `array_element.slt` | `array_element` / `array_extract` / `list_extract` | | `array_min_max.slt` | `array_max`, `array_min` | | `array_pop.slt` | `array_pop_back`, `array_pop_front` | | `array_slice.slt` | `array_slice` / `list_slice` | | `array_any_value.slt` | `array_any_value` / `list_any_value` | | `array_sort.slt` | `array_sort` / `list_sort` | | `array_append.slt` | `array_append` / `list_append` / `array_push_back` | | `array_prepend.slt` | `array_prepend` / `list_prepend` / `array_push_front` | | `array_repeat.slt` | `array_repeat` / `list_repeat` | | `array_concat.slt` | `array_concat` / `array_cat` / `list_concat` | | `array_position.slt` | `array_position` / `array_positions` | | `array_replace.slt` | `array_replace` / `array_replace_n` / `array_replace_all` | | `array_to_string.slt` | `array_to_string` / `array_join` / `list_join` | | `array_union.slt` | `array_union` / `list_union` | | `array_remove.slt` | `array_remove` / `array_remove_n` / `array_remove_all` | | `array_length.slt` | `array_length` / `array_dims` / `array_ndims` / `array_distance` | | `array_has.slt` | `array_has` / `array_has_all` / `array_has_any` | | `array_distinct.slt` | `array_distinct` / `array_compact` | | `arrays_zip.slt` | `arrays_zip` / `list_zip` | | `array_range.slt` | `range` / `generate_series` | | `array_except.slt` | `array_except` | | `array_operators.slt` | Array concat (`\|\|`), containment (`@>`) operators | | `array_cast.slt` | Array casting, `FixedSizeList`, `flatten` | | `array_empty.slt` | `empty` / `array_empty` / `list_empty` | | `string_to_array.slt` | `string_to_array` | | `array_resize.slt` | `array_resize` | | `array_reverse.slt` | `array_reverse` + misc edge cases | <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent 3b5008a commit 9873357

35 files changed

Lines changed: 10695 additions & 10044 deletions

datafusion/sqllogictest/src/test_file.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,17 @@ impl Ord for TestFile {
112112
/// 3. 3.336s imdb.slt
113113
/// 4. 3.085s push_down_filter_regression.slt
114114
/// 5. 2.926s aggregate_skip_partial.slt
115-
/// 6. 2.453s array.slt
116-
/// 7. 2.399s window.slt
117-
/// 8. 2.198s group_by.slt
118-
/// 9. 1.281s clickbench.slt
119-
/// 10. 1.058s datetime/timestamps.slt
115+
/// 6. 2.399s window.slt
116+
/// 7. 2.198s group_by.slt
117+
/// 8. 1.281s clickbench.slt
118+
/// 9. 1.058s datetime/timestamps.slt
120119
/// ```
121120
const TEST_PRIORITY_ENTRIES: &[&str] = &[
122121
"aggregate.slt", // longest-running files go first
123122
"joins.slt",
124123
"imdb.slt",
125124
"push_down_filter_regression.slt",
126125
"aggregate_skip_partial.slt",
127-
"array.slt",
128126
"window.slt",
129127
"group_by.slt",
130128
"clickbench.slt",

datafusion/sqllogictest/test_files/array.slt

Lines changed: 0 additions & 10038 deletions
This file was deleted.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
include ./init_data.slt.part
19+
20+
## array_any_value (aliases: list_any_value)
21+
22+
# Testing with empty arguments should result in an error
23+
query error
24+
select array_any_value();
25+
26+
# Testing with non-array arguments should result in an error
27+
query error
28+
select array_any_value(1), array_any_value('a'), array_any_value(NULL);
29+
30+
# array_any_value scalar function #1 (with null and non-null elements)
31+
32+
query IT?I
33+
select array_any_value(make_array(NULL, 1, 2, 3, 4, 5)), array_any_value(make_array(NULL, 'h', 'e', 'l', 'l', 'o')), array_any_value(make_array(NULL, NULL)), array_any_value(make_array(NULL, NULL, 1, 2, 3));
34+
----
35+
1 h NULL 1
36+
37+
query ITITI
38+
select array_any_value(arrow_cast(make_array(NULL, 1, 2, 3, 4, 5), 'LargeList(Int64)')), array_any_value(arrow_cast(make_array(NULL, 'h', 'e', 'l', 'l', 'o'), 'LargeList(Utf8)')), array_any_value(arrow_cast(make_array(NULL, NULL), 'LargeList(Int64)')), array_any_value(arrow_cast(make_array(NULL, NULL), 'LargeList(Utf8)')), array_any_value(arrow_cast(make_array(NULL, NULL, 1, 2, 3), 'LargeList(Int64)'));;
39+
----
40+
1 h NULL NULL 1
41+
42+
query ITITI
43+
select array_any_value(arrow_cast(make_array(NULL, 1, 2, 3, 4, 5), 'FixedSizeList(6, Int64)')), array_any_value(arrow_cast(make_array(NULL, 'h', 'e', 'l', 'l', 'o'), 'FixedSizeList(6, Utf8)')), array_any_value(arrow_cast(make_array(NULL, NULL), 'FixedSizeList(2, Int64)')), array_any_value(arrow_cast(make_array(NULL, NULL), 'FixedSizeList(2, Utf8)')), array_any_value(arrow_cast(make_array(NULL, NULL, 1, 2, 3, 4), 'FixedSizeList(6, Int64)'));
44+
----
45+
1 h NULL NULL 1
46+
47+
# array_any_value scalar function #2 (with nested array)
48+
49+
query ?
50+
select array_any_value(make_array(NULL, make_array(NULL, 1, 2, 3, 4, 5), make_array(NULL, 6, 7, 8, 9, 10)));
51+
----
52+
[NULL, 1, 2, 3, 4, 5]
53+
54+
query ?
55+
select array_any_value(arrow_cast(make_array(NULL, make_array(NULL, 1, 2, 3, 4, 5), make_array(NULL, 6, 7, 8, 9, 10)), 'LargeList(List(Int64))'));
56+
----
57+
[NULL, 1, 2, 3, 4, 5]
58+
59+
query ?
60+
select array_any_value(arrow_cast(make_array(NULL, make_array(NULL, 1, 2, 3, 4, 5), make_array(NULL, 6, 7, 8, 9, 10)), 'FixedSizeList(3, List(Int64))'));
61+
----
62+
[NULL, 1, 2, 3, 4, 5]
63+
64+
# array_any_value scalar function #3 (using function alias `list_any_value`)
65+
query IT
66+
select list_any_value(make_array(NULL, 1, 2, 3, 4, 5)), list_any_value(make_array(NULL, 'h', 'e', 'l', 'l', 'o'));
67+
----
68+
1 h
69+
70+
query IT
71+
select list_any_value(arrow_cast(make_array(NULL, 1, 2, 3, 4, 5), 'LargeList(Int64)')), list_any_value(arrow_cast(make_array(NULL, 'h', 'e', 'l', 'l', 'o'), 'LargeList(Utf8)'));
72+
----
73+
1 h
74+
75+
query IT
76+
select list_any_value(arrow_cast(make_array(NULL, 1, 2, 3, 4, 5), 'FixedSizeList(6, Int64)')), list_any_value(arrow_cast(make_array(NULL, 'h', 'e', 'l', 'l', 'o'), 'FixedSizeList(6, Utf8)'));
77+
----
78+
1 h
79+
80+
# array_any_value with columns
81+
82+
query I
83+
select array_any_value(column1) from slices;
84+
----
85+
2
86+
11
87+
21
88+
31
89+
NULL
90+
41
91+
51
92+
93+
query I
94+
select array_any_value(arrow_cast(column1, 'LargeList(Int64)')) from slices;
95+
----
96+
2
97+
11
98+
21
99+
31
100+
NULL
101+
41
102+
51
103+
104+
query I
105+
select array_any_value(column1) from fixed_slices;
106+
----
107+
2
108+
11
109+
21
110+
31
111+
41
112+
51
113+
114+
# array_any_value with columns and scalars
115+
116+
query II
117+
select array_any_value(make_array(NULL, 1, 2, 3, 4, 5)), array_any_value(column1) from slices;
118+
----
119+
1 2
120+
1 11
121+
1 21
122+
1 31
123+
1 NULL
124+
1 41
125+
1 51
126+
127+
query II
128+
select array_any_value(arrow_cast(make_array(NULL, 1, 2, 3, 4, 5), 'LargeList(Int64)')), array_any_value(arrow_cast(column1, 'LargeList(Int64)')) from slices;
129+
----
130+
1 2
131+
1 11
132+
1 21
133+
1 31
134+
1 NULL
135+
1 41
136+
1 51
137+
138+
query II
139+
select array_any_value(make_array(NULL, 1, 2, 3, 4, 5)), array_any_value(column1) from fixed_slices;
140+
----
141+
1 2
142+
1 11
143+
1 21
144+
1 31
145+
1 41
146+
1 51
147+
148+
# make_array with nulls
149+
query ???????
150+
select make_array(make_array('a','b'), null),
151+
make_array(make_array('a','b'), null, make_array('c','d')),
152+
make_array(null, make_array('a','b'), null),
153+
make_array(null, make_array('a','b'), null, null, make_array('c','d')),
154+
make_array(['a', 'bc', 'def'], null, make_array('rust')),
155+
make_array([1,2,3], null, make_array(4,5,6,7)),
156+
make_array(null, 1, null, 2, null, 3, null, null, 4, 5);
157+
----
158+
[[a, b], NULL] [[a, b], NULL, [c, d]] [NULL, [a, b], NULL] [NULL, [a, b], NULL, NULL, [c, d]] [[a, bc, def], NULL, [rust]] [[1, 2, 3], NULL, [4, 5, 6, 7]] [NULL, 1, NULL, 2, NULL, 3, NULL, NULL, 4, 5]
159+
160+
query ?
161+
select make_array(column5, null, column5) from arrays_values_without_nulls;
162+
----
163+
[[2, 3], NULL, [2, 3]]
164+
[[4, 5], NULL, [4, 5]]
165+
[[6, 7], NULL, [6, 7]]
166+
[[8, 9], NULL, [8, 9]]
167+
168+
query ?
169+
select make_array(['a','b'], null);
170+
----
171+
[[a, b], NULL]
172+
173+
174+
include ./cleanup.slt.part

0 commit comments

Comments
 (0)