Skip to content

Commit 27e665d

Browse files
committed
Add test
1 parent 6572fb4 commit 27e665d

1 file changed

Lines changed: 79 additions & 9 deletions

File tree

datafusion/sqllogictest/test_files/array.slt

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,31 @@ AS VALUES
347347

348348
statement ok
349349
CREATE TABLE array_distinct_table_1D_large
350+
AS SELECT
351+
arrow_cast(column1, 'LargeList(Int64)') AS column1
352+
FROM array_distinct_table_1D
353+
;
354+
355+
statement ok
356+
CREATE TABLE array_distinct_table_1D_fixed
357+
AS SELECT
358+
arrow_cast(column1, 'FixedSizeList(5, Int64)') AS column1
359+
FROM array_distinct_table_1D
360+
;
361+
362+
statement ok
363+
CREATE TABLE array_distinct_table_1D_UTF8_fixed
364+
AS SELECT
365+
arrow_cast(column1, 'FixedSizeList(5, Utf8)') AS column1
366+
FROM array_distinct_table_1D_UTF8
367+
;
368+
369+
statement ok
370+
CREATE TABLE array_distinct_table_2D_fixed
350371
AS VALUES
351-
(arrow_cast(make_array(1, 1, 2, 2, 3), 'LargeList(Int64)')),
352-
(arrow_cast(make_array(1, 2, 3, 4, 5), 'LargeList(Int64)')),
353-
(arrow_cast(make_array(3, 5, 3, 3, 3), 'LargeList(Int64)'))
372+
(arrow_cast(make_array([1,2], [1,2], [3,4], [3,4], [5,6]), 'FixedSizeList(5, List(Int64))')),
373+
(arrow_cast(make_array([1,2], [3,4], [5,6], [7,8], [9,10]), 'FixedSizeList(5, List(Int64))')),
374+
(arrow_cast(make_array([5,6], [5,6], NULL, NULL, NULL), 'FixedSizeList(5, List(Int64))'))
354375
;
355376

356377
statement ok
@@ -2108,6 +2129,11 @@ select array_prepend(1, arrow_cast(make_array(2, 3, 4), 'LargeList(Int64)')), ar
21082129
----
21092130
[1, 2, 3, 4] [1.0, 2.0, 3.0, 4.0] [h, e, l, l, o]
21102131

2132+
query ???
2133+
select array_prepend(1, arrow_cast([2, 3, 4], 'FixedSizeList(3, Int64)')), array_prepend(1.0, arrow_cast([2.0, 3.0, 4.0], 'FixedSizeList(3, Float64)')), array_prepend('h', arrow_cast(['e', 'l', 'l', 'o'], 'FixedSizeList(4, Utf8)'));
2134+
----
2135+
[1, 2, 3, 4] [1.0, 2.0, 3.0, 4.0] [h, e, l, l, o]
2136+
21112137
# array_prepend scalar function #4 (element is list)
21122138
query ???
21132139
select array_prepend(make_array(1), make_array(make_array(2), make_array(3), make_array(4))), array_prepend(make_array(1.0), make_array([2.0], [3.0], [4.0])), array_prepend(make_array('h'), make_array(['e'], ['l'], ['l'], ['o']));
@@ -2121,6 +2147,13 @@ select array_prepend(arrow_cast(make_array(1), 'LargeList(Int64)'), arrow_cast(m
21212147
----
21222148
[[1], [2], [3], [4]] [[1.0], [2.0], [3.0], [4.0]] [[h], [e], [l], [l], [o]]
21232149

2150+
query ???
2151+
select array_prepend(arrow_cast([1], 'FixedSizeList(1, Int64)'), arrow_cast([[1], [2], [3]], 'FixedSizeList(3, List(Int64))')),
2152+
array_prepend(arrow_cast([1.0], 'FixedSizeList(1, Float64)'), arrow_cast([[2.0], [3.0], [4.0]], 'FixedSizeList(3, List(Float64))')),
2153+
array_prepend(arrow_cast(['h'], 'FixedSizeList(1, Utf8)'), arrow_cast([['e'], ['l'], ['l'], ['o']], 'FixedSizeList(4, List(Utf8))'));
2154+
----
2155+
[[1], [1], [2], [3]] [[1.0], [2.0], [3.0], [4.0]] [[h], [e], [l], [l], [o]]
2156+
21242157
# list_prepend scalar function #5 (function alias `array_prepend`)
21252158
query ???
21262159
select list_prepend(1, make_array(2, 3, 4)), list_prepend(1.0, make_array(2.0, 3.0, 4.0)), list_prepend('h', make_array('e', 'l', 'l', 'o'));
@@ -4309,12 +4342,12 @@ FROM array_ndims_table;
43094342

43104343
statement ok
43114344
CREATE TABLE fixed_array_ndims_table
4312-
AS SELECT
4313-
column1,
4314-
arrow_cast(column2, 'FixedSizeList(3, Int64)') as column2,
4315-
arrow_cast(column3, 'FixedSizeList(3, List(Int64))') as column3,
4316-
arrow_cast(column4, 'FixedSizeList(3, List(List(List(List(Int64)))))') as column4
4317-
FROM array_ndims_table;
4345+
AS VALUES
4346+
(arrow_cast([1], 'FixedSizeList(1, Int64)'), arrow_cast([1, 2, 3], 'FixedSizeList(3, Int64)'), arrow_cast([[7]], 'FixedSizeList(1, List(Int64))'), arrow_cast([[[[[10]]]]], 'FixedSizeList(1, List(List(List(List(Int64)))))')),
4347+
(arrow_cast([2], 'FixedSizeList(1, Int64)'), arrow_cast([4, 5, 6], 'FixedSizeList(3, Int64)'), arrow_cast([[8]], 'FixedSizeList(1, List(Int64))'), arrow_cast([[[[[10]]]]], 'FixedSizeList(1, List(List(List(List(Int64)))))')),
4348+
(null, arrow_cast([6, 7, 8], 'FixedSizeList(3, Int64)'), arrow_cast([[9]], 'FixedSizeList(1, List(Int64))'), arrow_cast([[[[[10]]]]], 'FixedSizeList(1, List(List(List(List(Int64)))))')),
4349+
(arrow_cast([3], 'FixedSizeList(1, Int64)'), arrow_cast([6, 7, 8], 'FixedSizeList(3, Int64)'), arrow_cast([[9]], 'FixedSizeList(1, List(Int64))'), arrow_cast([[[[[10]]]]], 'FixedSizeList(1, List(List(List(List(Int64)))))'))
4350+
;
43184351

43194352
query IIII
43204353
select
@@ -4342,6 +4375,19 @@ from large_array_ndims_table;
43424375
NULL 1 2 5
43434376
1 1 2 5
43444377

4378+
query IIII
4379+
select
4380+
array_ndims(column1),
4381+
array_ndims(column2),
4382+
array_ndims(column3),
4383+
array_ndims(column4)
4384+
from fixed_array_ndims_table;
4385+
----
4386+
1 1 2 5
4387+
1 1 2 5
4388+
NULL 1 2 5
4389+
1 1 2 5
4390+
43454391

43464392

43474393
statement ok
@@ -4844,6 +4890,30 @@ from array_distinct_table_1D_large;
48444890
[1, 2, 3, 4, 5]
48454891
[3, 5]
48464892

4893+
query ?
4894+
select array_distinct(column1)
4895+
from array_distinct_table_1D_fixed;
4896+
----
4897+
[1, 2, 3]
4898+
[1, 2, 3, 4, 5]
4899+
[3, 5]
4900+
4901+
query ?
4902+
select array_distinct(column1)
4903+
from array_distinct_table_1D_UTF8_fixed;
4904+
----
4905+
[a, bc, def]
4906+
[a, bc, def, defg]
4907+
[defg]
4908+
4909+
query ?
4910+
select array_distinct(column1)
4911+
from array_distinct_table_2D_fixed;
4912+
----
4913+
[[1, 2], [3, 4], [5, 6]]
4914+
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
4915+
[, [5, 6]]
4916+
48474917
query ???
48484918
select array_intersect(column1, column2),
48494919
array_intersect(column3, column4),

0 commit comments

Comments
 (0)