Skip to content

Snowflake: parse nested COPY transformation paths - #2518

Open
osipovartem wants to merge 1 commit into
apache:mainfrom
Embucket:upstream-snowflake-copy-nested-path
Open

osipovartem wants to merge 1 commit into
apache:mainfrom
Embucket:upstream-snowflake-copy-nested-path

Conversation

@osipovartem

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes no issue.

Rationale for this change

Snowflake permits nested semi-structured paths in staged COPY transformations, for example $1:country:name::VARCHAR. The dedicated simple staged-field parser currently consumes $1:country and leaves :name::VARCHAR behind, so the documented statement fails to parse.

Documentation: https://docs.snowflake.com/en/user-guide/tutorials/script-data-load-transform-parquet

What changes are included in this PR?

  • Fall back to the standard expression parser when a staged field is followed by another path operator, bracket access, qualification, or cast.
  • Extend the existing COPY cast-transformation test with the documented nested-path shape.

Simple staged fields keep their compact StageLoadSelectItem AST; only complex expressions use the existing JsonAccess / Cast AST.

Are there any user-facing changes?

Yes. Snowflake COPY statements with nested staged paths now parse and round-trip correctly.

How was this change tested?

  • cargo test --test sqlparser_snowflake (164 passed)
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check

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.

1 participant