@@ -754,7 +754,7 @@ fn parse_alter_external_table(parser: &mut Parser) -> Result<Statement, ParserEr
754754 // Optional subpath for refreshing specific partitions
755755 let subpath = match parser. peek_token ( ) . token {
756756 Token :: SingleQuotedString ( s) => {
757- parser. next_token ( ) ;
757+ parser. advance_token ( ) ;
758758 Some ( s)
759759 }
760760 _ => None ,
@@ -1155,14 +1155,14 @@ pub fn parse_create_database(
11551155pub fn parse_storage_serialization_policy (
11561156 parser : & mut Parser ,
11571157) -> Result < StorageSerializationPolicy , ParserError > {
1158- let next_token = parser. next_token ( ) ;
1159- match & next_token . token {
1160- Token :: Word ( w ) => match w . keyword {
1161- Keyword :: COMPATIBLE => Ok ( StorageSerializationPolicy :: Compatible ) ,
1162- Keyword :: OPTIMIZED => Ok ( StorageSerializationPolicy :: Optimized ) ,
1163- _ => parser . expected ( "storage_serialization_policy" , next_token ) ,
1164- } ,
1165- _ => parser. expected ( "storage_serialization_policy" , next_token ) ,
1158+ let keyword = match & parser. next_token_ref ( ) . token {
1159+ Token :: Word ( w ) => w . keyword ,
1160+ _ => Keyword :: NoKeyword ,
1161+ } ;
1162+ match keyword {
1163+ Keyword :: COMPATIBLE => Ok ( StorageSerializationPolicy :: Compatible ) ,
1164+ Keyword :: OPTIMIZED => Ok ( StorageSerializationPolicy :: Optimized ) ,
1165+ _ => parser. expected_at ( "storage_serialization_policy" , parser . get_current_index ( ) ) ,
11661166 }
11671167}
11681168
@@ -1258,22 +1258,19 @@ pub fn parse_stage_name_identifier(parser: &mut Parser) -> Result<Ident, ParserE
12581258/// Parses a Snowflake stage name, which may start with `@` for internal stages.
12591259/// Examples: `@mystage`, `@namespace.stage`, `schema.table`
12601260pub fn parse_snowflake_stage_name ( parser : & mut Parser ) -> Result < ObjectName , ParserError > {
1261- match parser. next_token ( ) . token {
1262- Token :: AtSign => {
1263- parser. prev_token ( ) ;
1264- let mut idents = vec ! [ ] ;
1265- loop {
1266- idents. push ( parse_stage_name_identifier ( parser) ?) ;
1267- if !parser. consume_token ( & Token :: Period ) {
1268- break ;
1269- }
1261+ let is_at_sign = parser. next_token_ref ( ) . token == Token :: AtSign ;
1262+ parser. prev_token ( ) ;
1263+ if is_at_sign {
1264+ let mut idents = vec ! [ ] ;
1265+ loop {
1266+ idents. push ( parse_stage_name_identifier ( parser) ?) ;
1267+ if !parser. consume_token ( & Token :: Period ) {
1268+ break ;
12701269 }
1271- Ok ( ObjectName :: from ( idents) )
1272- }
1273- _ => {
1274- parser. prev_token ( ) ;
1275- Ok ( parser. parse_object_name ( false ) ?)
12761270 }
1271+ Ok ( ObjectName :: from ( idents) )
1272+ } else {
1273+ Ok ( parser. parse_object_name ( false ) ?)
12771274 }
12781275}
12791276
@@ -1381,7 +1378,7 @@ pub fn parse_copy_into(parser: &mut Parser) -> Result<Statement, ParserError> {
13811378 Token :: SingleQuotedString ( s) => files. push ( s) ,
13821379 _ => parser. expected ( "file token" , next_token) ?,
13831380 } ;
1384- if parser. next_token ( ) . token . eq ( & Token :: Comma ) {
1381+ if parser. next_token_ref ( ) . token == Token :: Comma {
13851382 continue_loop = true ;
13861383 } else {
13871384 parser. prev_token ( ) ; // not a comma, need to go back
@@ -1399,7 +1396,7 @@ pub fn parse_copy_into(parser: &mut Parser) -> Result<Statement, ParserError> {
13991396 // VALIDATION MODE
14001397 } else if parser. parse_keyword ( Keyword :: VALIDATION_MODE ) {
14011398 parser. expect_token ( & Token :: Eq ) ?;
1402- validation_mode = Some ( parser. next_token ( ) . token . to_string ( ) ) ;
1399+ validation_mode = Some ( parser. next_token_ref ( ) . to_string ( ) ) ;
14031400 // COPY OPTIONS
14041401 } else if parser. parse_keyword ( Keyword :: COPY_OPTIONS ) {
14051402 parser. expect_token ( & Token :: Eq ) ?;
@@ -1557,7 +1554,7 @@ fn parse_stage_params(parser: &mut Parser) -> Result<StageParamsObject, ParserEr
15571554 // STORAGE INTEGRATION
15581555 if parser. parse_keyword ( Keyword :: STORAGE_INTEGRATION ) {
15591556 parser. expect_token ( & Token :: Eq ) ?;
1560- storage_integration = Some ( parser. next_token ( ) . token . to_string ( ) ) ;
1557+ storage_integration = Some ( parser. next_token_ref ( ) . to_string ( ) ) ;
15611558 }
15621559
15631560 // ENDPOINT
0 commit comments