Skip to content

Commit 6c2f956

Browse files
committed
test: move find_in_set coverage to string extras
1 parent c70e7bf commit 6c2f956

3 files changed

Lines changed: 81 additions & 57 deletions

File tree

datafusion/sqllogictest/test_files/string/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ string/
3535
- large_string.slt // the entrypoint for large_string type
3636
- string_view.slt // the entrypoint for string_view type and the string_view specific tests
3737
- string_literal.slt // the tests for string literal
38+
- string_extra.slt // tests that need custom data or table setup
3839
```
3940

41+
The type-based entry point files run common setup for all tests, which makes
42+
additional per-test data or table setup harder to add. Tests that need custom
43+
setup should be placed in `string_extra.slt`.
44+
4045
## Pattern for Test Entry Point Files
4146

4247
Any entry point file should include `init_data.slt.part` and `string_query.slt.part`.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# Type-based string entry points run common setup for all tests, which makes
19+
# custom per-test data or table setup harder to add. Such tests belong here.
20+
21+
# find_in_set with an array on the left and a literal on the right
22+
query III
23+
SELECT
24+
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast('a,b,c', 'Utf8')),
25+
find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast('a,b,c', 'LargeUtf8')),
26+
find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast('a,b,c', 'Utf8View'))
27+
FROM (VALUES ('b'), ('x'), (NULL)) AS t(column1);
28+
----
29+
2 2 2
30+
0 0 0
31+
NULL NULL NULL
32+
33+
# find_in_set with a literal on the left and an array on the right
34+
query III
35+
SELECT
36+
find_in_set(arrow_cast('b', 'Utf8'), arrow_cast(column1, 'Utf8')),
37+
find_in_set(arrow_cast('b', 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8')),
38+
find_in_set(arrow_cast('b', 'Utf8View'), arrow_cast(column1, 'Utf8View'))
39+
FROM (VALUES ('a,b,c'), ('x,y'), (NULL)) AS t(column1);
40+
----
41+
2 2 2
42+
0 0 0
43+
NULL NULL NULL
44+
45+
# find_in_set with arrays on both sides
46+
query III
47+
SELECT
48+
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(column2, 'Utf8')),
49+
find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast(column2, 'LargeUtf8')),
50+
find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast(column2, 'Utf8View'))
51+
FROM (VALUES ('b', 'a,b,c'), ('x', 'x,y'), (NULL, 'a,b'), ('a', NULL)) AS t(column1, column2);
52+
----
53+
2 2 2
54+
1 1 1
55+
NULL NULL NULL
56+
NULL NULL NULL
57+
58+
# null literals paired with arrays
59+
query II
60+
SELECT
61+
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(NULL, 'Utf8')),
62+
find_in_set(arrow_cast(NULL, 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8'))
63+
FROM (VALUES ('a,b'), (NULL)) AS t(column1);
64+
----
65+
NULL NULL
66+
NULL NULL
67+
68+
# invalid argument count and type
69+
query error 'find_in_set' does not support zero arguments
70+
SELECT find_in_set();
71+
72+
query error No function matches the given name and argument types 'find_in_set\(Utf8\)'
73+
SELECT find_in_set('a');
74+
75+
query error No function matches the given name and argument types 'find_in_set\(Utf8, Utf8, Utf8\)'
76+
SELECT find_in_set('a', 'a,b', 'extra');

datafusion/sqllogictest/test_files/string/string_literal.slt

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -933,63 +933,6 @@ SELECT find_in_set(arrow_cast('', 'Utf8View'), arrow_cast('a,b,c,d,a', 'Utf8View
933933
----
934934
0
935935

936-
# find_in_set with an array on the left and a literal on the right
937-
query III
938-
SELECT
939-
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast('a,b,c', 'Utf8')),
940-
find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast('a,b,c', 'LargeUtf8')),
941-
find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast('a,b,c', 'Utf8View'))
942-
FROM (VALUES ('b'), ('x'), (NULL)) AS t(column1);
943-
----
944-
2 2 2
945-
0 0 0
946-
NULL NULL NULL
947-
948-
# find_in_set with a literal on the left and an array on the right
949-
query III
950-
SELECT
951-
find_in_set(arrow_cast('b', 'Utf8'), arrow_cast(column1, 'Utf8')),
952-
find_in_set(arrow_cast('b', 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8')),
953-
find_in_set(arrow_cast('b', 'Utf8View'), arrow_cast(column1, 'Utf8View'))
954-
FROM (VALUES ('a,b,c'), ('x,y'), (NULL)) AS t(column1);
955-
----
956-
2 2 2
957-
0 0 0
958-
NULL NULL NULL
959-
960-
# find_in_set with arrays on both sides
961-
query III
962-
SELECT
963-
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(column2, 'Utf8')),
964-
find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast(column2, 'LargeUtf8')),
965-
find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast(column2, 'Utf8View'))
966-
FROM (VALUES ('b', 'a,b,c'), ('x', 'x,y'), (NULL, 'a,b'), ('a', NULL)) AS t(column1, column2);
967-
----
968-
2 2 2
969-
1 1 1
970-
NULL NULL NULL
971-
NULL NULL NULL
972-
973-
# null literals paired with arrays
974-
query II
975-
SELECT
976-
find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(NULL, 'Utf8')),
977-
find_in_set(arrow_cast(NULL, 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8'))
978-
FROM (VALUES ('a,b'), (NULL)) AS t(column1);
979-
----
980-
NULL NULL
981-
NULL NULL
982-
983-
# invalid argument count and type
984-
query error DataFusion error:
985-
SELECT find_in_set();
986-
987-
query error DataFusion error:
988-
SELECT find_in_set('a');
989-
990-
query error DataFusion error:
991-
SELECT find_in_set('a', 'a,b', 'extra');
992-
993936

994937
query T
995938
SELECT split_part('foo_bar', '_', 2)

0 commit comments

Comments
 (0)