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

Snowflake drop column fixes #1618

Merged
merged 9 commits into from Oct 13, 2021

Conversation

myschkyna
Copy link
Contributor

Brief summary of the change made

Fixes #1617. Linting an 'alter table drop dolumn statement' raised an unparsable section error. Including this specific sequence fixes the issue.

Are there any other side effects of this change that we should be aware of?

Not that I'm aware of.

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not DBT tests are failing as your branch is out of sync with main and we fixed an issue in that. Merge from main (or use the Update branch button below to do that for you).

Comment on lines 791 to 802
OneOf("ALTER", "MODIFY", "DROP"),
OptionallyBracketed(
Delimited(
OneOf(
# Add things
Sequence(
Ref.keyword("COLUMN", optional=True),
Ref("SingleIdentifierGrammar"),
),
Sequence(
Ref.keyword("COLUMN", optional=True),
Ref("SingleIdentifierGrammar"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. The DROP syntax is supported further down but insists on column name before.

Should we either:

  1. Go with what you have, but remove the DROP from line 804? That would allow ALTER TABLE ALTER column1 which is not technically correct.
  2. Revert your change and make the column before it on line 802 optional? But that would allow ALTER TABLE ALTER SET NOT NULL which is not correct as column is missing.
  3. Wrap whole thing in a OneOf and leave ALTER and MODIFY alone but pull DROP into it's own path?

Option 3 Is probably the most correct to be honest.

What's your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I see your point. Will wrap the whole thing into an OneOf statement.

Copy link
Contributor Author

@myschkyna myschkyna Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tunetheweb I think it is now fixed. Could you have a look again. Because we wrapped everything into a OneOf statement, I also had to create a sequence for the 'old' path.

Ref.keyword("COLUMN", optional=True),
Ref("SingleIdentifierGrammar"),
OneOf(
Sequence(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the added sequence for simple drop column statement

Ref.keyword("COLUMN", optional=True),
Ref("SingleIdentifierGrammar"),
),
Sequence(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new sequence here, so that the OneOf wrapper 'understands' the steps following after the step OneOf("ALTER", "MODIFY") are related.

Copy link
Member

@tunetheweb tunetheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

GitHub Actions is experiencing some issues so looks like Windows tests are not running. Will merge this after they fix that.

@myschkyna
Copy link
Contributor Author

Thanks and cool @tunetheweb! Thanks for the fast replies again.

@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #1618 (e146a31) into main (633a23f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #1618   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          131       131           
  Lines         9208      9208           
=========================================
  Hits          9208      9208           
Impacted Files Coverage Δ
src/sqlfluff/dialects/dialect_snowflake.py 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 633a23f...e146a31. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snowflake / drop column: unparsable section for drop column statement
2 participants