Open the80srobot opened 2 weeks ago
Presto usually adheres to ANSI SQL spec, which is probably why we don't support this already. However, I think allowing trailing commas is a relatively harmless changes and generally removes a bunch of headaches with syntax errors when forgetting to remove the trailing comma. Many programming languages have adopted this style as well in argument lists (e.g. Python, Rust, TypeScript). I would be in favor of this improvement.
+1 as well.
I'm a weak -1. I prefer to avoid new discrepancies with ANSI SQL and also like to avoid multiple ways to do things.
I don't think this has been requested before, but I'd like to propose support for a trailing comma in SELECT. This is a convenience feature supported by some other dialects, most notably by Google SQL.
Expected Behavior or Use Case
Currently, this example from the Google SQL docs is not accepted in Presto:
Accepting the comma after "release_date" leads to no ambiguity and makes it easier to edit the query in the common case where columns are listed on separate lines:
Presto Component, Service, or Connector
SQL parser.
Possible Implementation
Specifically in
SqlBase.g4
we'd need to changeQuerySpecification
.The code in
com.facebook.presto.sql.parser
looks like it wouldn't need many changes.I don't propose having the formatter emit the trailing comma, so no changes would be required there.
Example Screenshots (if appropriate):
See above.
Context
This is useful for two reasons: