Describe the bug
The docs for map_extract say that it returns an empty list if the requested key is not present in the map, but that is not the implemented behavior: [NULL] is returned instead. This behavior does not match how map_extract behaves in DuckDB; it also makes it impossible to distinguish between an absent key and a key whose associated value is NULL, which is arguably the point of having map_extract return a list in the first place.
To Reproduce
SELECT
map_extract(MAP {'a': 1, 'b': NULL}, 'a') AS present,
map_extract(MAP {'a': 1, 'b': NULL}, 'b') AS present_null,
map_extract(MAP {'a': 1, 'b': NULL}, 'c') AS missing,
element_at(MAP {'a': 1, 'b': NULL}, 'c') AS alias_missing;
Verified using DataFusion CLI 55.0.0 and DuckDB v1.5.5:
| Engine |
present |
present_null |
missing |
alias_missing |
| DataFusion |
[1] |
[NULL] |
[NULL] |
[NULL] |
| DuckDB |
[1] |
[NULL] |
[] |
[] |
Expected behavior
map_extract should return [] for a missing key.
Additional context
No response
Describe the bug
The docs for
map_extractsay that it returns an empty list if the requested key is not present in the map, but that is not the implemented behavior:[NULL]is returned instead. This behavior does not match howmap_extractbehaves in DuckDB; it also makes it impossible to distinguish between an absent key and a key whose associated value isNULL, which is arguably the point of havingmap_extractreturn a list in the first place.To Reproduce
Verified using DataFusion CLI 55.0.0 and DuckDB v1.5.5:
[1][NULL][NULL][NULL][1][NULL][][]Expected behavior
map_extractshould return[]for a missing key.Additional context
No response