File tree 4 files changed +16
-2
lines changed
4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2354,6 +2354,7 @@ pub enum Statement {
2354
2354
cache_metadata : bool ,
2355
2355
noscan : bool ,
2356
2356
compute_statistics : bool ,
2357
+ has_table_keyword : bool ,
2357
2358
} ,
2358
2359
/// ```sql
2359
2360
/// TRUNCATE
@@ -3651,8 +3652,13 @@ impl fmt::Display for Statement {
3651
3652
cache_metadata,
3652
3653
noscan,
3653
3654
compute_statistics,
3655
+ has_table_keyword,
3654
3656
} => {
3655
- write ! ( f, "ANALYZE TABLE {table_name}" ) ?;
3657
+ write ! (
3658
+ f,
3659
+ "ANALYZE{}{table_name}" ,
3660
+ if * has_table_keyword { " TABLE " } else { " " }
3661
+ ) ?;
3656
3662
if let Some ( ref parts) = partitions {
3657
3663
if !parts. is_empty ( ) {
3658
3664
write ! ( f, " PARTITION ({})" , display_comma_separated( parts) ) ?;
Original file line number Diff line number Diff line change @@ -284,6 +284,7 @@ impl Spanned for Statement {
284
284
cache_metadata : _,
285
285
noscan : _,
286
286
compute_statistics : _,
287
+ has_table_keyword : _,
287
288
} => union_spans (
288
289
core:: iter:: once ( table_name. span ( ) )
289
290
. chain ( partitions. iter ( ) . flat_map ( |i| i. iter ( ) . map ( |k| k. span ( ) ) ) )
Original file line number Diff line number Diff line change @@ -851,7 +851,7 @@ impl<'a> Parser<'a> {
851
851
}
852
852
853
853
pub fn parse_analyze(&mut self) -> Result<Statement, ParserError> {
854
- self.expect_keyword (Keyword::TABLE)? ;
854
+ let has_table_keyword = self.parse_keyword (Keyword::TABLE);
855
855
let table_name = self.parse_object_name(false)?;
856
856
let mut for_columns = false;
857
857
let mut cache_metadata = false;
@@ -896,6 +896,7 @@ impl<'a> Parser<'a> {
896
896
}
897
897
898
898
Ok(Statement::Analyze {
899
+ has_table_keyword,
899
900
table_name,
900
901
for_columns,
901
902
columns,
Original file line number Diff line number Diff line change @@ -562,6 +562,12 @@ fn parse_select_with_table_alias() {
562
562
) ;
563
563
}
564
564
565
+ #[ test]
566
+ fn parse_analyze ( ) {
567
+ verified_stmt ( "ANALYZE TABLE test_table" ) ;
568
+ verified_stmt ( "ANALYZE test_table" ) ;
569
+ }
570
+
565
571
#[ test]
566
572
fn parse_invalid_table_name ( ) {
567
573
let ast = all_dialects ( ) . run_parser_method ( "db.public..customer" , |parser| {
You can’t perform that action at this time.
0 commit comments