goldmedal commented on issue #11268: URL: https://github.com/apache/datafusion/issues/11268#issuecomment-2211101833
Thanks @alamb @jayzhan211 > https://duckdb.org/docs/sql/data_types/map.html > > we can follow the syntax from DuckDB, `map_from_entries`, and convert the syntax `MAP {k: v, ...}` to function `map_from_entries` later It's a good idea. I also considered how to implement SQL syntax to support this scalar function, but I had no idea how to do it. It seems `UserDefinedSQLPlanner` is what I need. It's helpful for me. I will try to implement the syntax for `MAP { x : 1 }`. I guess I can follow how the `RawDictionaryExpr` works. Besides the SQL syntax, I'm considering what the scalar function would look like. Should we consider the data layout of `arrow::MapArray`? If needed, I think its parameters could be different from DuckDB's `map_from_entries` because the data layout of `arrow::MapArray` allows many slots for a map value, like: ``` [{a:1,b:2},{c:3},{d:4},{}] ``` The function would be used like this: ``` map_from_entries_array([a, 1, b, 2], [c, 3], [d,4], []) ``` If we don't need to consider it, we could only allow one element for `MapArray`. It would be similar to how `named_struct()` is used: ``` map_from_entries(a, 1, b, 2, c, 3) ``` The layout would be ``` [{a:1,b:2,c:3}] ``` What do you think? -- 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]
