sql-formatter-org / sql-formatter

A whitespace formatter for different query languages
https://sql-formatter-org.github.io/sql-formatter/
MIT License
2.37k stars 405 forks source link

[FORMATTING] Missing support for Snowflake lambda operator #789

Closed datarttu closed 1 month ago

datarttu commented 1 month ago

-> operator in Snowflake SQL dialect is currently formatted into - >. See Snowflake Lambda expressions for background.

Input data

Which SQL and options did you provide as input?

SELECT FILTER(some_array_of_objects_with_int_value, a -> a:value >= 50) AS "Filter >= 50";

Expected Output

SELECT
  FILTER (
    some_array_of_objects_with_int_value,
    a -> a:value >= 50
  ) AS "Filter >= 50";

Actual Output

SELECT
  FILTER (
    some_array_of_objects_with_int_value,
    a - > a:value >= 50
  ) AS "Filter >= 50";

Usage

datarttu commented 1 month ago

Could this be fixed with an addition to supported operators and related test(s)?

// https://docs.snowflake.com/en/user-guide/querying-semistructured#lambda-expressions
'->'

Unfortunately I don't currently have Node / ts environment set up to test my suggestion locally, but I'm happy to help in any way I can.

nene commented 1 month ago

Thanks for reporting. Yes, that would have been the fix to make.

nene commented 1 month ago

Released the fix in sql-formatter 15.4.5 and vscode plugin 4.1.3.

datarttu commented 1 month ago

Works like a charm. Thank you so much! 🎉