tree-sitter-sql icon indicating copy to clipboard operation
tree-sitter-sql copied to clipboard

Trailing Comma - Snowflake

Open ryaminal opened this issue 11 months ago • 4 comments

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?

ryaminal avatar Mar 19 '24 22:03 ryaminal

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

DerekStride avatar Mar 20 '24 13:03 DerekStride

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

ryaminal avatar Mar 20 '24 16:03 ryaminal

Adding it to the existing behaviour is good

DerekStride avatar Mar 21 '24 13:03 DerekStride

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.

matthias-Q avatar Apr 04 '24 21:04 matthias-Q