Skip to content

Commit

Permalink
Add tests for cardinality with fixed size lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Feb 8, 2024
1 parent 59923b4 commit 2f477b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datafusion/expr/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub enum ArrayFunctionSignature {
impl ArrayFunctionSignature {
/// Arguments to ArrayFunctionSignature
/// `current_types` - The data types of the arguments
/// `coercion` - Whether null type coercion is allowed
/// `allow_null_coercion` - Whether null type coercion is allowed
/// Returns the valid types for the function signature
pub fn get_type_signature(
&self,
Expand Down
28 changes: 28 additions & 0 deletions datafusion/sqllogictest/test_files/array.slt
Original file line number Diff line number Diff line change
Expand Up @@ -3770,6 +3770,11 @@ select cardinality(arrow_cast(make_array(1, 2, 3, 4, 5), 'LargeList(Int64)')), c
----
5 3 5

query III
select cardinality(arrow_cast([1, 2, 3, 4, 5], 'FixedSizeList(5, Int64)')), cardinality(arrow_cast([1, 3, 5], 'FixedSizeList(3, Int64)')), cardinality(arrow_cast(make_array('h', 'e', 'l', 'l', 'o'), 'FixedSizeList(5, Utf8)'));
----
5 3 5

# cardinality scalar function #2
query II
select cardinality(make_array([1, 2], [3, 4], [5, 6])), cardinality(array_repeat(array_repeat(array_repeat(3, 3), 2), 3));
Expand All @@ -3781,6 +3786,11 @@ select cardinality(arrow_cast(make_array([1, 2], [3, 4], [5, 6]), 'LargeList(Lis
----
6

query I
select cardinality(arrow_cast([[1, 2], [3, 4], [5, 6]], 'FixedSizeList(3, List(Int64))'));
----
6

# cardinality scalar function #3
query II
select cardinality(make_array()), cardinality(make_array(make_array()))
Expand All @@ -3792,6 +3802,13 @@ select cardinality(arrow_cast(make_array(), 'LargeList(Null)')), cardinality(arr
----
NULL 0

#TODO
#https://github.com/apache/arrow-datafusion/issues/9158
#query II
#select cardinality(arrow_cast(make_array(), 'FixedSizeList(1, Null)')), cardinality(arrow_cast(make_array(make_array()), 'FixedSizeList(1, List(Null))'))
#----
#NULL 0

# cardinality with columns
query III
select cardinality(column1), cardinality(column2), cardinality(column3) from arrays;
Expand All @@ -3815,6 +3832,17 @@ NULL 3 4
4 NULL 1
4 3 NULL

query III
select cardinality(column1), cardinality(column2), cardinality(column3) from fixed_size_arrays;
----
4 3 5
4 3 5
4 3 5
4 3 3
NULL 3 4
4 NULL 1
4 3 NULL

## array_remove (aliases: `list_remove`)

# array_remove scalar function #1
Expand Down

0 comments on commit 2f477b2

Please sign in to comment.