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

Feature Request: Snowflake Function Wrap Indentation #785

Closed TheBigfella closed 1 month ago

TheBigfella commented 1 month ago

Describe the Feature When lines wrap within functions, the current formatter starts a newline following the opening parentheses, then left aligns the items within the parentheses to the first character of the function name.

SELECT A,
       B,
       COALESCE(THIS_IS_A_LONG_COLUMN_NAME, THIS_IS_AN_EVEN_LONGER_COLUMN_NAME) AS LONG_COLUMN_ALIAS,
       C
  FROM TABLE
 WHERE ABC = 'example'

Becomes:

SELECT A,
       B,
       COALESCE(
       THIS_IS_A_LONG_COLUMN_NAME,
       THIS_IS_AN_EVEN_LONGER_COLUMN_NAME
       ) AS LONG_COLUMN_ALIAS,
       C
  FROM TABLE
 WHERE ABC = 'example'

It would be better if the function indented slightly on the newline to allow for the select list items to be visualised more easily.:

SELECT A,
       B,
       COALESCE(
         THIS_IS_A_LONG_COLUMN_NAME,
         THIS_IS_AN_EVEN_LONGER_COLUMN_NAME
       ) AS LONG_COLUMN_ALIAS,
       C
  FROM TABLE
 WHERE ABC = 'example'
TheBigfella commented 1 month ago

Turns out this is because of selecting tabularRight in the Indent Style setting.