iffyio commented on code in PR #1805: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1805#discussion_r2038845330
########## src/dialect/snowflake.rs: ########## @@ -866,86 +867,97 @@ pub fn parse_copy_into(parser: &mut Parser) -> Result<Statement, ParserError> { fn parse_select_items_for_data_load( parser: &mut Parser, -) -> Result<Option<Vec<StageLoadSelectItem>>, ParserError> { - // [<alias>.]$<file_col_num>[.<element>] [ , [<alias>.]$<file_col_num>[.<element>] ... ] - let mut select_items: Vec<StageLoadSelectItem> = vec![]; +) -> Result<Option<Vec<StageLoadSelectItemKind>>, ParserError> { + let mut select_items: Vec<StageLoadSelectItemKind> = vec![]; loop { - let mut alias: Option<Ident> = None; - let mut file_col_num: i32 = 0; - let mut element: Option<Ident> = None; - let mut item_as: Option<Ident> = None; + match parser.maybe_parse(parse_select_item_for_data_load)? { + // [<alias>.]$<file_col_num>[.<element>] [ , [<alias>.]$<file_col_num>[.<element>] ... ] + Some(item) => select_items.push(StageLoadSelectItemKind::StageLoadSelectItem(item)), + // Fallback, try to parse a standard SQL select item + None => select_items.push(StageLoadSelectItemKind::SelectItem( + parser.parse_select_item()?, + )), + } + match parser.next_token().token { + Token::Comma => { + // continue + } + _ => { + parser.prev_token(); // need to move back + break; + } + } Review Comment: could we do something like this in order to avoid the token clone here? ```rust if matches!(parser.peek_token_ref(), Token::Comma) { parser.advance() } else { break } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org