izveigor commented on code in PR #7207:
URL: https://github.com/apache/arrow-datafusion/pull/7207#discussion_r1285066898
##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -1892,7 +1903,7 @@ select array_length(array_fill(3, [3, 2, 5]), 1),
array_length(array_fill(3, [3,
query III
select array_length(make_array()), array_length(make_array(), 1),
array_length(make_array(), 2)
----
-0 0 NULL
+1 1 NULL
Review Comment:
It is some weird that `array_length` function with an empty array returns
`1`. I didn't find any famous databases with the same functionality.
The examples from our reference databases:
<b>PostgreSQL:</b>
```
postgres=# select array_length(array[]::integer[], 1);
array_length
--------------
(1 row)
postgres=# select array_dims(array[]::integer[]);
array_dims
------------
(1 row)
```
<b>DuckDB:</b>
```
D select array_length(list_value());
┌────────────────────────────┐
│ array_length(list_value()) │
│ int64 │
├────────────────────────────┤
│ 0 │
└────────────────────────────┘
```
<b>ClickHouse:</b>
```
SELECT length([])
Query id: 372b933e-18da-4ab4-bc20-87ce003f0d21
┌─length([])─┐
│ 0 │
└────────────┘
```
##########
datafusion/core/tests/sqllogictests/test_files/array.slt:
##########
@@ -1892,7 +1903,7 @@ select array_length(array_fill(3, [3, 2, 5]), 1),
array_length(array_fill(3, [3,
query III
select array_length(make_array()), array_length(make_array(), 1),
array_length(make_array(), 2)
----
-0 0 NULL
+1 1 NULL
Review Comment:
It is some weird that `array_length` function with an empty array returns
`1`. I didn't find any famous databases with the same functionality.
The examples from our reference databases:
<b>PostgreSQL:</b>
```
postgres=# select array_length(array[]::integer[], 1);
array_length
--------------
(1 row)
postgres=# select array_dims(array[]::integer[]);
array_dims
------------
(1 row)
```
<b>DuckDB:</b>
```
D select array_length(list_value());
┌────────────────────────────┐
│ array_length(list_value()) │
│ int64 │
├────────────────────────────┤
│ 0 │
└────────────────────────────┘
```
<b>ClickHouse:</b>
```
SELECT length([])
Query id: 372b933e-18da-4ab4-bc20-87ce003f0d21
┌─length([])─┐
│ 0 │
└────────────┘
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]