sqlfluff / sqlfluff

A modular SQL linter and auto-formatter with support for multiple dialects and templated code.
https://www.sqlfluff.com
MIT License
7.64k stars 696 forks source link

Some window functions are unparsable for snowflake dialect #5608

Closed gavagyan-rbi closed 6 months ago

gavagyan-rbi commented 7 months ago

Search before asking

Issue/Suggested Improvement

Trying to parse query with window function: select sum(TEST) over (partition by TEST1) AS SUM_TEST from TEST_TABLE;

Yields: `[L: 1, P: 1] |file: [L: 1, P: 1] | statement: [L: 1, P: 1] | select_statement: [L: 1, P: 1] | select_clause: [L: 1, P: 1] | keyword: 'select' [L: 1, P: 7] | [META] indent: [L: 1, P: 7] | newline: '\n' [L: 2, P: 1] | whitespace: ' ' [L: 2, P: 5] | select_clause_element: [L: 2, P: 5] | column_reference: [L: 2, P: 5] | naked_identifier: 'sumDATA' [L: 2, P: 14] | whitespace: ' ' [L: 2, P: 15] | alias_expression: [L: 2, P: 15] | [META] indent: [L: 2, P: 15] | naked_identifier: 'over' [L: 2, P: 19] | [META] dedent: [L: 2, P: 19] | [META] dedent: [L: 2, P: 19] | whitespace: ' ' [L: 2, P: 20] | unparsable: !! Expected: 'Nothing here.' [L: 2, P: 20] | start_bracket: '(' [L: 2, P: 21] | word: 'partition' [L: 2, P: 30] | whitespace: ' ' [L: 2, P: 31] | word: 'by' [L: 2, P: 33] | whitespace: ' ' [L: 2, P: 34] | word: 'TEST1' [L: 2, P: 39] | end_bracket: ')' [L: 2, P: 40] | whitespace: ' ' [L: 2, P: 41] | word: 'AS' [L: 2, P: 43] | whitespace: ' ' [L: 2, P: 44] | word: 'SUM_TEST' [L: 2, P: 52] | newline: '\n' [L: 3, P: 1] | from_clause: [L: 3, P: 1] | keyword: 'from' [L: 3, P: 5] | whitespace: ' ' [L: 3, P: 6] | from_expression: [L: 3, P: 6] | [META] indent: [L: 3, P: 6] | from_expression_element: [L: 3, P: 6] | table_expression: [L: 3, P: 6] | table_reference: [L: 3, P: 6] | naked_identifier: 'TEST_TABLE' [L: 3, P: 16] | [META] dedent: [L: 3, P: 16] | statement_terminator: ';' [L: 3, P: 17] | newline: '\n' [L: 4, P: 1] | [META] end_of_file:

==== parsing violations ==== L: 2 | P: 20 | PRS | Line 2, Position 18: Found unparsable section: '(partition by | TEST1) AS SUM_TEST'`

Happends for sum, avg, round, but works for row_number or rank

Code of Conduct

WittierDinosaur commented 6 months ago

I've just tested this on the latest release for all of the above window functions, and it works in snowflake. I'm going to close this issue. From the parsing output above, it looks like the test case you used was missing an opening bracket after the sum.