@@ -4438,6 +4438,13 @@ pub enum Statement {
44384438 /// ```
44394439 /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
44404440 CreateUser ( CreateUser ) ,
4441+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
4442+ ///
4443+ /// ```sql
4444+ /// VACUUM tbl
4445+ /// ```
4446+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
4447+ Vacuum ( VacuumStatement ) ,
44414448}
44424449
44434450/// ```sql
@@ -6372,6 +6379,7 @@ impl fmt::Display for Statement {
63726379 Statement :: ExportData ( e) => write ! ( f, "{e}" ) ,
63736380 Statement :: CreateUser ( s) => write ! ( f, "{s}" ) ,
63746381 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
6382+ Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
63756383 }
63766384 }
63776385}
@@ -10633,6 +10641,50 @@ impl fmt::Display for InitializeKind {
1063310641 }
1063410642}
1063510643
10644+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
10645+ ///
10646+ /// '''sql
10647+ /// VACUUM [ FULL | SORT ONLY | DELETE ONLY | REINDEX | RECLUSTER ] [ \[ table_name \] [ TO threshold PERCENT ] \[ BOOST \] ]
10648+ /// '''
10649+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
10650+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10651+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10652+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10653+ pub struct VacuumStatement {
10654+ pub full : bool ,
10655+ pub sort_only : bool ,
10656+ pub delete_only : bool ,
10657+ pub reindex : bool ,
10658+ pub recluster : bool ,
10659+ pub table_name : Option < ObjectName > ,
10660+ pub threshold : Option < Value > ,
10661+ pub boost : bool ,
10662+ }
10663+
10664+ impl fmt:: Display for VacuumStatement {
10665+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10666+ write ! (
10667+ f,
10668+ "VACUUM{}{}{}{}{}" ,
10669+ if self . full { " FULL" } else { "" } ,
10670+ if self . sort_only { " SORT ONLY" } else { "" } ,
10671+ if self . delete_only { " DELETE ONLY" } else { "" } ,
10672+ if self . reindex { " REINDEX" } else { "" } ,
10673+ if self . recluster { " RECLUSTER" } else { "" } ,
10674+ ) ?;
10675+ if let Some ( table_name) = & self . table_name {
10676+ write ! ( f, " {table_name}" ) ?;
10677+ }
10678+ if let Some ( threshold) = & self . threshold {
10679+ write ! ( f, " TO {threshold} PERCENT" ) ?;
10680+ }
10681+ if self . boost {
10682+ write ! ( f, " BOOST" ) ?;
10683+ }
10684+ Ok ( ( ) )
10685+ }
10686+ }
10687+
1063610688#[ cfg( test) ]
1063710689mod tests {
1063810690 use crate :: tokenizer:: Location ;
0 commit comments