8000 feat(snowflake): add support for 'DROP ICEBERG TABLE' statement by VishalSinha1103 · Pull Request #6860 · sqlfluff/sqlfluff · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(snowflake): add support for 'DROP ICEBERG TABLE' statement #6860

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

Merged
merged 5 commits into from
May 4, 2025

Conversation

VishalSinha1103
Copy link
Contributor
@VishalSinha1103 VishalSinha1103 commented May 2, 2025

Added a new segment DropIcebergTableStatementSegment in the Snowflake dialect to support parsing of DROP ICEBERG TABLE [IF EXISTS] <table_name> syntax.

fixes #6859

Changes made:

  • Defined DropIcebergTableStatementSegment with appropriate match_grammar using Sequence, Ref, and IfExistsGrammar.
  • Registered the new segment via snowflake_dialect.add(...).

This change resolves issues with SQLFluff failing to parse valid Snowflake statements involving Iceberg tables, such as:

DROP ICEBERG TABLE IF EXISTS SAMPLE_DEV.SAMPLE.CASH;

Helps avoid parse errors like:
PRS | Found unparsable section: 'DROP ICEBERG TABLE IF EXISTS ...'

Brief summary of the change made

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

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 in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

Added a new segment `DropIcebergTableStatementSegment` in the Snowflake dialect to support parsing of `DROP ICEBERG TABLE [IF EXISTS] <table_name>` syntax.

Changes made:
- Defined `DropIcebergTableStatementSegment` with appropriate `match_grammar` using `Sequence`, `Ref`, and `IfExistsGrammar`.
- Registered the new segment via `snowflake_dialect.add(...)`.

This change resolves issues with SQLFluff failing to parse valid Snowflake statements involving Iceberg tables, such as:

    DROP ICEBERG TABLE IF EXISTS SAMPLE_DEV.SAMPLE.CASH;

Helps avoid parse errors like:
    PRS | Found unparsable section: 'DROP ICEBERG TABLE IF EXISTS ...'
Copy link
Contributor
@WittierDinosaur WittierDinosaur left a comment

Choose a reason for hiding this comment

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

LGTM

@WittierDinosaur WittierDinosaur enabled auto-merge May 2, 2025 18:48
Copy link
Contributor
github-actions bot commented May 2, 2025

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   19637      0   100%

249 files skipped due to complete coverage.

auto-merge was automatically disabled May 3, 2025 14:31

Head branch was pushed to by a user without write access

@VishalSinha1103
Copy link
Contributor Author

Hi @WittierDinosaur can you approve the pr again as some test fails which required rerun now after new commits

Added a parser test case for the new DROP ICEBERG TABLE syntax in the Snowflake dialect. This file includes example SQL statements to validate that the dialect correctly parses the new segment implemented in `dialect_snowflake.py`.

The corresponding YAML file will be generated using `tox -e generate-fixture-yml`.
@WittierDinosaur
Copy link
Contributor

Somehow you've got rid of the yml. Run python test/generate_parse_fixture_yml.py -d snowflake

Generated .yml file from .sql file using
 python test/generate_parse_fixture_yml.py -d snowflake
@VishalSinha1103
Copy link
Contributor Author

Somehow you've got rid of the yml. Run python test/generate_parse_fixture_yml.py -d snowflake

No Danny , The .yml file isn't auto generated due to which some test cases failed , so again it requires the approval.

@WittierDinosaur WittierDinosaur enabled auto-merge May 4, 2025 12:55
@WittierDinosaur WittierDinosaur added this pull request to the merge queue May 4, 2025
Merged via the queue into sqlfluff:main with commit 4ea000c May 4, 2025
28 checks passed
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.

Support for DROP ICEBERG TABLE syntax in Snowflake dialect
2 participants
0