Skip to content

Commit a108022

Browse files
committed
test: add array_sort sqllogictest for null and invalid types
1 parent aad419c commit a108022

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

datafusion/sqllogictest/test_files/array.slt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,36 @@ select array_sort([]);
22652265
----
22662266
[]
22672267

2268+
# test with null arguments
2269+
query error
2270+
select array_sort(NULL);
2271+
----
2272+
DataFusion error: Error during planning: Failed to coerce arguments to satisfy a call to 'array_sort' function: coercion from [Null] to the signature OneOf([ArraySignature(Array { arguments: [Array], array_coercion: None }), ArraySignature(Array { arguments: [Array, DataType(Utf8)], array_coercion: None }), ArraySignature(Array { arguments: [Array, DataType(Utf8), DataType(Utf8)], array_coercion: None })]) failed No function matches the given name and argument types 'array_sort(Null)'. You might need to add explicit type casts.
2273+
Candidate functions:
2274+
array_sort(array)
2275+
array_sort(array, Utf8)
2276+
array_sort(array, Utf8, Utf8)
2277+
2278+
2279+
query ?
2280+
select array_sort([1, 3, null, 5, NULL, -5], NULL);
2281+
----
2282+
NULL
2283+
2284+
query ??
2285+
select array_sort([1, 3, null, 5, NULL, -5], 'DESC', NULL), array_sort([1, 3, null, 5, NULL, -5], 'ASC', NULL);
2286+
----
2287+
NULL NULL
2288+
2289+
query ??
2290+
select array_sort([1, 3, null, 5, NULL, -5], NULL, 'NULLS FIRST'), array_sort([1, 3, null, 5, NULL, -5], NULL, 'NULLS LAST');
2291+
----
2292+
NULL NULL
2293+
2294+
## test with argument of incorrect types
2295+
query error DataFusion error: Execution error: the second parameter of array_sort expects DESC or ASC
2296+
select array_sort([1, 3, null, 5, NULL, -5], 1), array_sort([1, 3, null, 5, NULL, -5], 'DESC', 1), array_sort([1, 3, null, 5, NULL, -5], 1, 1);
2297+
22682298
# test with empty row, the row that does not match the condition has row count 0
22692299
statement ok
22702300
create table t1(a int, b int) as values (100, 1), (101, 2), (102, 3), (101, 2);

0 commit comments

Comments
 (0)