Skip to content

Extended the Snowflake COPY INTO data-load select item parser to support nested semi-structured path traversal#2223

Open
romanoff wants to merge 2 commits intoapache:mainfrom
romanoff:snowflake_copy_into_nested_semi_structured_path_traversal_support
Open

Extended the Snowflake COPY INTO data-load select item parser to support nested semi-structured path traversal#2223
romanoff wants to merge 2 commits intoapache:mainfrom
romanoff:snowflake_copy_into_nested_semi_structured_path_traversal_support

Conversation

@romanoff
Copy link
Contributor

Extended the Snowflake COPY INTO data-load select item parser to support nested semi-structured path traversal (e.g. $1:a:b:c) by looping over consecutive :element segments instead of consuming only one.

Example of query:

COPY INTO tbl (col) FROM (SELECT $1:a:b AS col FROM @stage)

Comment on lines +1515 to +1516
} else if let Token::Word(w) = parser.peek_token().token {
if !RESERVED_FOR_COLUMN_ALIAS.contains(&w.keyword) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make sense to somehow reuse the is_column_alias method for this dialect instead?

Also can we add test cases that cover this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iffyio Updated PR

@romanoff romanoff force-pushed the snowflake_copy_into_nested_semi_structured_path_traversal_support branch from ca092cf to 6dccdeb Compare March 3, 2026 23:05

/// Optionally parses an alias for a select list item
fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, ParserError> {
pub fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, ParserError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, ParserError> {
pub(crate) fn maybe_parse_select_item_alias(&mut self) -> Result<Option<Ident>, ParserError> {

Token::Word(w) => Ok(Ident::new(w.value)),
_ => parser.expected_ref("column item alias", parser.peek_token_ref()),
}?);
parser.prev_token();
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be possible to rewrite the code so that it peeks the expected Token::Colon before entering the loop? if that would let us avoid this call to prev_token()

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.

2 participants