@@ -4409,6 +4409,13 @@ pub enum Statement {
44094409 /// ```
44104410 /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
44114411 CreateUser ( CreateUser ) ,
4412+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
4413+ ///
4414+ /// ```sql
4415+ /// VACUUM tbl
4416+ /// ```
4417+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
4418+ Vacuum ( VacuumStatement ) ,
44124419}
44134420
44144421/// ```sql
@@ -6343,6 +6350,7 @@ impl fmt::Display for Statement {
63436350 Statement :: ExportData ( e) => write ! ( f, "{e}" ) ,
63446351 Statement :: CreateUser ( s) => write ! ( f, "{s}" ) ,
63456352 Statement :: AlterSchema ( s) => write ! ( f, "{s}" ) ,
6353+ Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
63466354 }
63476355 }
63486356}
@@ -10604,6 +10612,50 @@ impl fmt::Display for InitializeKind {
1060410612 }
1060510613}
1060610614
10615+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
10616+ ///
10617+ /// '''sql
10618+ /// VACUUM [ FULL | SORT ONLY | DELETE ONLY | REINDEX | RECLUSTER ] [ \[ table_name \] [ TO threshold PERCENT ] \[ BOOST \] ]
10619+ /// '''
10620+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
10621+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10622+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10623+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10624+ pub struct VacuumStatement {
10625+ pub full : bool ,
10626+ pub sort_only : bool ,
10627+ pub delete_only : bool ,
10628+ pub reindex : bool ,
10629+ pub recluster : bool ,
10630+ pub table_name : Option < ObjectName > ,
10631+ pub threshold : Option < Value > ,
10632+ pub boost : bool ,
10633+ }
10634+
10635+ impl fmt:: Display for VacuumStatement {
10636+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10637+ write ! (
10638+ f,
10639+ "VACUUM{}{}{}{}{}" ,
10640+ if self . full { " FULL" } else { "" } ,
10641+ if self . sort_only { " SORT ONLY" } else { "" } ,
10642+ if self . delete_only { " DELETE ONLY" } else { "" } ,
10643+ if self . reindex { " REINDEX" } else { "" } ,
10644+ if self . recluster { " RECLUSTER" } else { "" } ,
10645+ ) ?;
10646+ if let Some ( table_name) = & self . table_name {
10647+ write ! ( f, " {table_name}" ) ?;
10648+ }
10649+ if let Some ( threshold) = & self . threshold {
10650+ write ! ( f, " TO {threshold} PERCENT" ) ?;
10651+ }
10652+ if self . boost {
10653+ write ! ( f, " BOOST" ) ?;
10654+ }
10655+ Ok ( ( ) )
10656+ }
10657+ }
10658+
1060710659#[ cfg( test) ]
1060810660mod tests {
1060910661 use crate :: tokenizer:: Location ;
0 commit comments