-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
ALTER WAREHOUSE Snowflaken statements do no support variables or single quotes #4937
Comments
I'm seeing that the ALTER WAREHOUSE statement uses Ref("NakedIdentifierSegment", optional=True) in the code.
However, I'm seeing that other ALTER STATEMENTS (e.g. alter storage integration) use Ref("ObjectReferenceSegment") instead. Like the example here:
Could it be the case that we need to use ObjectReferenceSegment for ALTER WAREHOUSE statements instead of NakedIdentifierSegment? |
Hi @Orangemic, For the
There is no possibility for quotes. I think you can add the possibility quite easily, take inspiration from other places in the code :) PS: All the clauses after the |
For the You can find NakedIdentifierSegment=SegmentGenerator(
# Generate the anti template from the set of reserved keywords
lambda dialect: RegexParser(
# See https://docs.snowflake.com/en/sql-reference/identifiers-syntax.html
r"[a-zA-Z_][a-zA-Z0-9_$]*",
ansi.IdentifierSegment,
type="naked_identifier",
anti_template=r"^(" + r"|".join(dialect.sets("reserved_keywords")) + r")$",
)
), So there is no mention of any IDENTIFIER thing, I think Have a try at it if you like and I can help if needed :) |
Search before asking
What Happened
Using the SQLParse Snowflake dialect, PRS errors are given on ALTER WAREHOUSE statements whereby either variables are used to describe the warehouse (e.g. IDENTIFIER($var)) or when using single quotes after a SET statement (e.g. SET WAREHOUSE_TYPE = 'STANDARD').
Expected Behaviour
Using IDENTIFIER($var) and single quotes after a SET statement should not give PRS issues.
Observed Behaviour
Running this code gives PRS errors in SQLFluff using the Snowflake dialect, whereby the code is completed without errors in Snowflake itself:
ALTER WAREHOUSE IDENTIFIER($var_wh) SET WAREHOUSE_TYPE = STANDARD;
ALTER WAREHOUSE WH_TEST SET SCALING_POLICY = 'ECONOMY';
Running the code without the 'IDENTIFIER($var_wh)' or single quotes around ECONOMY, gives no PRS issues:
ALTER WAREHOUSE WH_TEST SET WAREHOUSE_TYPE = STANDARD;
ALTER WAREHOUSE WH_TEST SET SCALING_POLICY = ECONOMY;
How to reproduce
See here a link to where the code breaks.
In this example the code would run without PRS errors.
Dialect
I use the Snowflake dialect
Version
Configuration
Honestly, our config is still pretty empty at this point:
[sqlfluff]
dialect = snowflake
Are you willing to work on and submit a PR to address the issue?
Code of Conduct
The text was updated successfully, but these errors were encountered: