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
Make Snowflake keywords unreserved: account, organization, pivot #2172
Conversation
After moving pivot to unreserved_keywords this query now won't parse: SELECT * FROM my_tbl
PIVOT (min(f_val) FOR f_id IN (1, 2)) AS f (a, b); Reason being the parser sees the SELECT * FROM my_tbl PIVOT
-- Rest is not unparsable
(min(f_val) FOR f_id IN (1, 2)) AS f (a, b); Any ideas to get around this? |
Is there a way to differentiate between |
@BorePlusPlus yeah it's a bit of a weird one as when this gets parsed we have tokens like: Since a token like However, now we've made
I think there is might be a way to terminate the I don't currently have access to Snowflake atm, but if you do I'm curious if this is fine in snowflake: SELECT * FROM my_tbl PIVOT i.e. can we use pivot as a table alias if the pivot isn't being used as a function? |
Codecov Report
@@ Coverage Diff @@
## main #2172 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 148 148
Lines 10777 10777
=========================================
Hits 10777 10777
Continue to review full report at Codecov.
|
@@ -621,6 +621,7 @@ class ObjectReferenceSegment(BaseSegment): | |||
Ref("BinaryOperatorGrammar"), | |||
Ref("ColonSegment"), | |||
Ref("DelimiterSegment"), | |||
Ref("JoinLikeClauseGrammar"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BorePlusPlus btw this is what I needed to add to stop the parser getting confused about whether PIVOT
is an alias or a function.
Basically for an ObjectReferenceSegment
, which is inherited by TableReferenceSegment
, it will stop matching when the subsequent token is part of JoinLikeClauseGrammar
, which contains the FromPivotExpressionSegment
in Snowflake.
Brief summary of the change made
Fixes #2165 and fixes #2164. A couple snowflake keywords were being conservatively included in reserved when they shouldn't be. Moving them to non_reserved accordingly.
Are there any other side effects of this change that we should be aware of?
No
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.