@@ -8410,16 +8410,9 @@ impl<'a> Parser<'a> {
8410
8410
} else {
8411
8411
let columns = self . parse_parenthesized_column_list ( Optional , is_mysql) ?;
8412
8412
8413
- let partitioned = self . parse_insert_partition ( ) ?;
8414
-
8415
- // make sure we are not about to consume a query
8416
- let mut after_columns = vec ! [ ] ;
8417
- match self . peek_nth_token ( 1 ) . token {
8418
- Token :: Word ( w) if w. keyword != Keyword :: SELECT => {
8419
- // Hive allows you to specify columns after partitions as well if you want.
8420
- after_columns = self . parse_parenthesized_column_list ( Optional , false ) ?;
8421
- }
8422
- _ => { }
8413
+ let ( partitioned, after_columns) = match self . parse_insert_partition ( ) ? {
8414
+ Some ( ( partitioned, after_columns) ) => ( Some ( partitioned) , after_columns) ,
8415
+ None => ( None , vec ! [ ] )
8423
8416
} ;
8424
8417
8425
8418
let source = Some ( Box :: new ( self . parse_query ( ) ?) ) ;
@@ -8500,12 +8493,16 @@ impl<'a> Parser<'a> {
8500
8493
}
8501
8494
}
8502
8495
8503
- pub fn parse_insert_partition ( & mut self ) -> Result < Option < Vec < Expr > > , ParserError > {
8496
+ pub fn parse_insert_partition ( & mut self ) -> Result < Option < ( Vec < Expr > , Vec < Ident > ) > , ParserError > {
8504
8497
if self . parse_keyword ( Keyword :: PARTITION ) {
8505
8498
self . expect_token ( & Token :: LParen ) ?;
8506
- let partition_cols = Some ( self . parse_comma_separated ( Parser :: parse_expr) ?) ;
8499
+ let partition_cols = self . parse_comma_separated ( Parser :: parse_expr) ?;
8507
8500
self . expect_token ( & Token :: RParen ) ?;
8508
- Ok ( partition_cols)
8501
+
8502
+ // Hive allows you to specify columns after partitions as well if you want.
8503
+ let after_columns = self . parse_parenthesized_column_list ( Optional , false ) ?;
8504
+
8505
+ Ok ( Some ( ( partition_cols, after_columns) ) )
8509
8506
} else {
8510
8507
Ok ( None )
8511
8508
}
0 commit comments