-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add map literal syntax #25276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add map literal syntax #25276
Conversation
The proposed syntax is too similar to a function call, but has very subtle differences (keys in place of argument names, arbitrary numbers of arguments) that make it confusing and potentially ambiguous. For instance, consider the following case:
where For map literals, I'd prefer to go more traditional syntax, such as See previous discussions on this topic: prestodb/presto#5065 |
Updated to the |
Rehashing some additional conversations we had over Slack, for future reference. I like that the It could be argued that using this syntax for Trino maps prevents us from using it in the future for more general struct-like entities. Today, the way to create struct-like values in Trino is via JSON_OBJECT and the JSON type. |
This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack. |
Description
This PR adds a simple map literal syntax to the grammar. The grammar is similar to JSON object creation except that keys can be any hashable type.
Under the covers the literal is translated to map_from_entries.
Examples
Release notes
(X) Release notes are required, with the following suggested text: