neilconway opened a new issue, #24981:
URL: https://github.com/apache/datafusion/issues/24981

   ### 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
   
     ```sql
     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_


-- 
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]

Reply via email to