Skip to content

Snowflake - COLLATE infix notation results in parser error #6917

@lester-swo

Description

@lester-swo

Search before asking

  • I searched the issues and found no similar issues.

What Happened

Input a simple example:

CREATE TABLE t2 AS SELECT col1 COLLATE 'fr' AS col1 FROM t1;

(taken from snowflake docs at https://docs.snowflake.com/en/sql-reference/collation)

Output received from running sqlfluff -v --dialect snowflake .\collation.snowql:

==== sqlfluff ====
sqlfluff:                3.4.0 python:                 3.11.9
implementation:        cpython verbosity:                   1
dialect:             snowflake templater:               jinja
rules:                                all
==== readout ====

== [collation.snowql] FAIL
L:   1 | P:  32 | AL02 | Implicit/explicit aliasing of columns.
                       | [aliasing.column]
L:   1 | P:  32 | CP02 | Unquoted identifiers must be consistently lower case.
                       | [capitalisation.identifiers]
L:   1 | P:  32 | RF04 | Keywords should not be used as identifiers.
                       | [references.keywords]
L:   1 | P:  40 |  PRS | Line 1, Position 40: Found unparsable section: "'fr' AS
                       | col1"
WARNING: Parsing errors found and dialect is set to 'snowflake'. Have you configured your dialect correctly?
==== summary ====
violations:        4 status:         FAIL
All Finished 📜 🎉!

Expected Behaviour

As it is an official example it should pass parsing at the minimum.

Observed Behaviour

It detected RF04 at L:1 P:32 so I deduce that the parser doesn't expect a COLLATE and probably isn't programmed to handle infix notation.

How to reproduce

I have outlined the steps in the above section. Github doesn't allow me to upload the .snowql file so just paste the one liner into a file and run the linter on it.

Dialect

snowflake

Version

sqlfluff: 3.4.0 python: 3.11.9

Configuration

[sqlfluff]
sql_file_exts = .sql,.sql.j2,.dml,.ddl,.snowql

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsnowflakeIssues related to the Snowflake dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions