DerekStride / tree-sitter-sql

SQL grammar for tree-sitter
http://derek.stride.host/tree-sitter-sql/
MIT License
147 stars 47 forks source link

Trailing Comma - Snowflake #244

Open ryaminal opened 5 months ago

ryaminal commented 5 months ago

Curious what the thoughts are on supporting a trailing comma in SQL? Snowflake just announced support for this in their dialect. Example:

SELECT emp_id,
       name,
       dept,
FROM employees;

This doesn't appear to be handled by tree-sitter-sql yet(as it was just announced) but curious if this is something tree-sitter-sql wants to support? Or would it be better to make a dialect-specific repo?

DerekStride commented 5 months ago

I'm up for adding it! You interested in writing the PR?

ryaminal commented 5 months ago

yeah, i'll give it a go. do you want it behind a flag or anything?

DerekStride commented 5 months ago

Adding it to the existing behaviour is good

matthias-Q commented 5 months ago

Not sure if I am a fan of adding the trailing comma. This is a convenience addition by snowflake and - as of now - is only supported by snowflake. It saved me more than once to see an error in the highlighting, when having a trailing comma that my query engines (postgres/impala/athena) do not accept. Since this parser does not distinguish between dialects it would not through an error.

In this particular case it would not be wise to be permissive.