Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions datafusion/sqllogictest/test_files/array/array_length.slt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,52 @@ select list_distance([1, 2, 3], [1, 2, 3]) AS distance;
----
0

# array_distance with null outer arrays
query RR
select
array_distance(arrow_cast(NULL, 'List(Float64)'), [1, 2]),
array_distance([1, 2], arrow_cast(NULL, 'List(Float64)'));
----
NULL NULL

# nested large-list inputs and nested nulls on either side

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this behavior, need some further investigation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a bug, array_distance() should only support 1-D array, multi-dimensional array distance should not be supported.

I'll open a fix later.

query R
select array_distance(
arrow_cast([[1, 2]], 'LargeList(LargeList(Float64))'),
arrow_cast([[1, 4]], 'LargeList(LargeList(Float64))')
);
----
2

query RR
select
array_distance(
arrow_cast([[1, NULL]], 'LargeList(LargeList(Float64))'),
arrow_cast([[1, 2]], 'LargeList(LargeList(Float64))')
),
array_distance(
arrow_cast([[1, 2]], 'LargeList(LargeList(Float64))'),
arrow_cast([[1, NULL]], 'LargeList(LargeList(Float64))')
);
----
NULL NULL

# invalid argument count and types
query error DataFusion error:
select array_distance();

query error DataFusion error:
select array_distance([1]);

query error DataFusion error:
select array_distance([1], [2], [3]);

query error array_distance does not support type Int64
select array_distance(1, [1]);

query error array_distance does not support types
select array_distance([1], arrow_cast([1], 'LargeList(Float64)'));

# array_distance with columns
query RRR
select array_distance(column1, column2), array_distance(column1, column3), array_distance(column1, column4) from arrays_distance_table;
Expand Down
Loading