Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLFluff can't parse object literals in Snowflake #3606

Closed
2 of 3 tasks
NiallRees opened this issue Jul 14, 2022 · 3 comments · Fixed by #3620
Closed
2 of 3 tasks

SQLFluff can't parse object literals in Snowflake #3606

NiallRees opened this issue Jul 14, 2022 · 3 comments · Fixed by #3620
Labels
enhancement New feature or request snowflake Issues related to the Snowflake dialect

Comments

@NiallRees
Copy link
Member

NiallRees commented Jul 14, 2022

Search before asking

  • I searched the issues and found no similar issues.

Description

Sqlfluff currently can't parse:

select
    {'a': 1, 'b': 2},
    [1,2,3]
==== parsing violations ====
L:   1 | P:   1 |  PRS | Line 1, Position 1: Found unparsable section: "select\n {'a': 1,
                       | 'b': 2},\n [1,2,3]..."

These are valid literals in Snowflake:
image

Use case

No response

Dialect

Snowflake

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

@NiallRees NiallRees added enhancement New feature or request snowflake Issues related to the Snowflake dialect labels Jul 14, 2022
@alanmcruickshank
Copy link
Member

I'm not surprised about object literals, but I thought that array literals were already covered 🤔 . I'll take a look at this.

@alanmcruickshank
Copy link
Member

alanmcruickshank commented Jul 15, 2022

For me, array literals do parse successfully:

select [1,2,3] as foo
$ sqlfluff parse test.sql --dialect snowflake --code-only
[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:  8]      |                select_clause_element:
[L:  1, P:  8]      |                    expression:
[L:  1, P:  8]      |                        array_literal:
[L:  1, P:  8]      |                            start_square_bracket:             '['
[L:  1, P:  9]      |                            expression:
[L:  1, P:  9]      |                                literal:                      '1'
[L:  1, P: 10]      |                            comma:                            ','
[L:  1, P: 11]      |                            expression:
[L:  1, P: 11]      |                                literal:                      '2'
[L:  1, P: 12]      |                            comma:                            ','
[L:  1, P: 13]      |                            expression:
[L:  1, P: 13]      |                                literal:                      '3'
[L:  1, P: 14]      |                            end_square_bracket:               ']'
[L:  1, P: 16]      |                    alias_expression:
[L:  1, P: 16]      |                        keyword:                              'as'
[L:  1, P: 19]      |                        identifier:                           'foo'

I agree that object literals don't. e.g.

select {'a': 1} as foo

@NiallRees - can you confirm?

@alanmcruickshank alanmcruickshank changed the title SQLFluff can't parse object and array literals in Snowflake SQLFluff can't parse object literals in Snowflake Jul 15, 2022
@NiallRees
Copy link
Member Author

Ah yes it does work for arrays. Thanks for that @alanmcruickshank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request snowflake Issues related to the Snowflake dialect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants