silver-ymz opened a new issue, #20526: URL: https://github.com/apache/datafusion/issues/20526
### Describe the bug When executing a query to get the `cardinality()` of an explicitly casted empty array (e.g., `[]::int[]`), DataFusion returns `NULL`. In standard SQL behavior across most database engines (such as PostgreSQL, DuckDB, and ClickHouse), the cardinality or length of an empty array is `0`. Returning `NULL` implies the array itself is null or unknown, which is incorrect for an explicitly defined empty array. ### To Reproduce Run the following query in the DataFusion CLI: ```sql ❯ select cardinality([]::int[]); +---------------------------+ | cardinality(make_array()) | +---------------------------+ | NULL | +---------------------------+ 1 row(s) fetched. ### Expected behavior +---------------------------+ | cardinality(make_array()) | +---------------------------+ | 0 | +---------------------------+ ### Additional context DataFusion version: DataFusion CLI v52.1.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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
