Skip to content

Snowflake: Fix CREATE DATABASE and COPY INTO consuming semicolon delimiter - #2790

Closed
slopgobblercobbler wants to merge 1 commit into
apache:mainfrom
slopgobblercobbler:fix/snowflake-create-db-copy-semicolon
Closed

slopgobblercobbler wants to merge 1 commit into
apache:mainfrom
slopgobblercobbler:fix/snowflake-create-db-copy-semicolon

Conversation

@slopgobblercobbler

Copy link
Copy Markdown

Dialects: snowflake

Description

Fixes #2765.

In parse_create_database and parse_copy_into, trailing option loops consumed tokens via parser.next_token() and broke on Token::SemiColon | Token::EOF without restoring the consumed token. As a result, when either statement was followed by a delimiter ; in a multi-statement query (e.g. CREATE DATABASE my_db; SELECT 1 or COPY INTO my_table FROM @my_stage; SELECT 1), the semicolon had already been swallowed from the token stream, causing statement separation to fail with Expected: end of statement, found: SELECT.

This change updates both loops to inspect upcoming tokens with parser.peek_token(), advancing with advance_token() only when consuming known keywords or options. Delimiters and unexpected tokens break out cleanly without being consumed, keeping statement separation intact.

Tests

  • Added multi-statement separation test cases in tests/sqlparser_snowflake.rs:
    • CREATE DATABASE my_db; SELECT 1
    • COPY INTO my_table FROM @my_stage; SELECT 1
  • Verified all 168 Snowflake dialect tests pass (cargo test --test sqlparser_snowflake).
  • Verified cargo clippy --all-targets passes with 0 warnings.

@LucaCappelletti94 LucaCappelletti94 added the Prolific Author author has opened PRs in many repositories in the last month label Nov 1, 2026
@alamb

alamb commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for the contribution. The change may well be correct, but I am closing this PR under the DataFusion AI policy, which also applies to sqlparser-rs: https://datafusion.apache.org/contributor-guide/ai-policy.html#what-is-an-ai-dump-and-why-it-is-not-helpful

Maintainer review time is the scarcest resource in this project. This account has recently opened many AI-generated PRs across many repositories. That suggests the changes aren't coming from someone who uses sqlparser-rs, and that no human will be around to discuss review feedback and maintain the code. Reviewing PRs like this costs us more time than it saves.

If you do use sqlparser-rs and this fix matters to you, please pick the one change you care most about. Then open a focused PR with a short description in your own words, one you have reviewed and understand, and we'd be happy to help with review.

@alamb alamb closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Prolific Author author has opened PRs in many repositories in the last month Snowflake

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snowflake: CREATE DATABASE and COPY INTO consume the ;, so the next statement is rejected

3 participants