fn array_length_of_dim(array: ListRef<'_>, d: i32) -> Result<Option<i32>>
Expand description
Returns the length of the requested array dimension.
Examples:
query I
select array_length(array[2,3,4], 1);
----
3
query I
select array_length(array[2,3,4], 0);
----
NULL
query I
select array_length(array[2,3,4], -1);
----
NULL
query I
select array_length(array[2,3,4], null);
----
NULL
query I
select array_length(array[array[2,3,4],array[3,4,5]], '1');
----
2
statement error
select array_length(array[2,3,4], true);
# This one could be supported later, but at the cost of checking all subarrays, to reject the next.
statement error
select array_length(array[array[2,3,4],array[3,4,5]], 2);
statement error
select array_length(array[array[2,3],array[3,4,5]], 2);
# Different from PostgreSQL who treats empty `array[]` as zero dimension and returns NULL.
query I
select array_length(array[]::int[], 1);
----
0
query I
select array_length(array[]::int[][], 1);
----
0
# This should be NULL but it is hard to access `DataType` in current expression framework.
# The next should remain rejected.
statement error
select array_length(array[1,2,3], 2);
statement error
select array_length(array[null, array[2]], 2);