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

Unparsable section with Snowflake dialect and a table named "account" #1927

Closed
leoch20 opened this issue Nov 18, 2021 · 6 comments
Closed

Unparsable section with Snowflake dialect and a table named "account" #1927

leoch20 opened this issue Nov 18, 2021 · 6 comments
Labels
bug Something isn't working dbt Related to Data Build Tool snowflake Issues related to the Snowflake dialect

Comments

@leoch20
Copy link

leoch20 commented Nov 18, 2021

{{config(
    materialized = "table",
    schema = "public"
)}}

select *
from {{ source('src','tbl') }} 

Expected Behaviour

Linting this should not raise any errors

Observed Behaviour

The following error gets raised

L:   8 | P:   1 |  PRS | Line 4, Position 1: Found unparsable section: 'from                                                                                                                                                                                                                                                                                                 
                       | raw.src.tbl'

Steps to Reproduce

Run sqlfluff lint filename.sql having the code above in the file

Dialect

Snowflake + dbt

Version

Include the output of sqlfluff --version along with your Python version

SQLFluff - sqlfluff, version 0.8.1
Python3 - Python 3.7.10-slim

Configuration

[sqlfluff]
templater = dbt
dialect = snowflake
verbose = 1
exclude_rules = L001,L003,L007,L008,L009,L011,L016,L029,L031,L034

[sqlfluff:templater:dbt]
project_dir = .
profiles_dir = .
profile = snowflake

[tool.sqlfluff.templater.jinja]
apply_dbt_builtins = True

[sqlfluff:rules]
max_line_length = 300

[sqlfluff:indentation]
indented_joins = True

[sqlfluff:rules:L003]
indent_unit = tab

[sqlfluff:rules:L010]
capitalisation_policy = lower

[sqlfluff:rules:L013]
allow_scalar = False

[sqlfluff:rules:L042]
forbid_subquery_in = both
@leoch20 leoch20 added the bug Something isn't working label Nov 18, 2021
@tunetheweb tunetheweb added the dbt Related to Data Build Tool label Nov 19, 2021
@BorePlusPlus
Copy link

I am hitting the same issue. It only seems to be impacting some sources, but works for most of them.
I am using sqlfluff 0.8.2 and jinja templater.

@BorePlusPlus
Copy link

BorePlusPlus commented Dec 14, 2021

Saw that the new version (0.9.0) was released and I tested with it. I tried both jinja and dbt templaters and I hit the same issue in both.
I'm using dbt 1.0.0

@BorePlusPlus
Copy link

OK - narrowed it down a bit. In my particular case, the things break when I use a source called account. It seems to work otherwise.

@BorePlusPlus
Copy link

I can pinpoint this to commit related to Snowflake dialect improvements (#1737). If I install a version that doesn't include this code (e.g. 0.7.1), queries parse without a problem.

After it, if I use account as a table name or alias, unparsable section errors are raised.

@leoch20
Copy link
Author

leoch20 commented Jan 12, 2022

We still have this issue after upgrading dbt to 1.0.0 and sqlfluff to 0.9.1.
For example, a query containing more than one order by 1 throws this error for only one of them (The all have the same formatting).

L: 185 | P:  15 |  PRS | Line 183, Position 15: Found unparsable section: '\n
                       | order by 1'

@barrywhart barrywhart added the snowflake Issues related to the Snowflake dialect label Jan 18, 2022
@barrywhart barrywhart changed the title Unparsable section when using dbt source Unparsable section with Snowflake dialect and a table named "account" Jan 18, 2022
@tunetheweb
Copy link
Member

The account issue was fixed in #2172 included in 0.9.1

I've just checked and this parses:

echo "SELECT * from raw.src.tbl" | sqlfluff parse --dialect snowflake -

Please raise issues with the full SQL (without DBT templates if at all possible) and not just the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dbt Related to Data Build Tool snowflake Issues related to the Snowflake dialect
Projects
None yet
Development

No branches or pull requests

4 participants