David-Wobrock / sqlvalidator

SQL queries formatting, syntactic and semantic validation

Home Page:https://pypi.org/project/sqlvalidator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with chained functions

Agyar opened this issue Β· comments

Hello πŸ‘‹

thank you for this awesome tool :). I have some issues with queries as the one below:

- COUNT(IF(STARTS_WITH(val, 'a'), 1, NULL) AS count_val,
- COUNT(DISTINCT IF(STARTS_WITH(val, 'a'), val_id, NULL)) AS count_val_unique
-FROM `{table_name}`
-GROUP BY
- dst_id,
- bitmask
-ORDER BY dst_id
+ COUNT(IF(STARTS_WITH(val, 'a'), 1, NULL) AS count_val, COUNT(DISTINCT IF(STARTS_WITH(val, 'a'), val_id, NULL)) AS count_val_unique, bitmask ORDER)

I actually don't think it's an issue with the sqlvalidator

The first function doesn't have it's closing parenthesis:

COUNT(IF(STARTS_WITH(val, 'a'), 1, NULL)) AS count_val,
                                        +

When adding this, the formatter happens correctly :)
Closing for now