@@ -69,8 +69,8 @@ pub use self::ddl::{
6969 IdentityProperty , IdentityPropertyFormatKind , IdentityPropertyKind , IdentityPropertyOrder ,
7070 IndexColumn , IndexOption , IndexType , KeyOrIndexDisplay , NullsDistinctOption , Owner , Partition ,
7171 ProcedureParam , ReferentialAction , RenameTableNameKind , ReplicaIdentity , TableConstraint ,
72- TagsColumnOption , UserDefinedTypeCompositeAttributeDef , UserDefinedTypeRepresentation ,
73- ViewColumnDef ,
72+ TagsColumnOption , Truncate , UserDefinedTypeCompositeAttributeDef ,
73+ UserDefinedTypeRepresentation , ViewColumnDef ,
7474} ;
7575pub use self :: dml:: { Delete , Insert } ;
7676pub use self :: operator:: { BinaryOperator , UnaryOperator } ;
@@ -3133,23 +3133,7 @@ pub enum Statement {
31333133 /// TRUNCATE
31343134 /// ```
31353135 /// Truncate (Hive)
3136- Truncate {
3137- table_names : Vec < TruncateTableTarget > ,
3138- partitions : Option < Vec < Expr > > ,
3139- /// TABLE - optional keyword;
3140- table : bool ,
3141- /// Postgres-specific option
3142- /// [ RESTART IDENTITY | CONTINUE IDENTITY ]
3143- identity : Option < TruncateIdentityOption > ,
3144- /// Postgres-specific option
3145- /// [ CASCADE | RESTRICT ]
3146- cascade : Option < CascadeOption > ,
3147- /// ClickHouse-specific option
3148- /// [ ON CLUSTER cluster_name ]
3149- ///
3150- /// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/truncate/)
3151- on_cluster : Option < Ident > ,
3152- } ,
3136+ Truncate ( Truncate ) ,
31533137 /// ```sql
31543138 /// MSCK
31553139 /// ```
@@ -4373,6 +4357,12 @@ impl From<Analyze> for Statement {
43734357 }
43744358}
43754359
4360+ impl From < ddl:: Truncate > for Statement {
4361+ fn from ( truncate : ddl:: Truncate ) -> Self {
4362+ Statement :: Truncate ( truncate)
4363+ }
4364+ }
4365+
43764366/// ```sql
43774367/// {COPY | REVOKE} CURRENT GRANTS
43784368/// ```
@@ -4589,45 +4579,7 @@ impl fmt::Display for Statement {
45894579 }
45904580 Ok ( ( ) )
45914581 }
4592- Statement :: Truncate {
4593- table_names,
4594- partitions,
4595- table,
4596- identity,
4597- cascade,
4598- on_cluster,
4599- } => {
4600- let table = if * table { "TABLE " } else { "" } ;
4601-
4602- write ! (
4603- f,
4604- "TRUNCATE {table}{table_names}" ,
4605- table_names = display_comma_separated( table_names)
4606- ) ?;
4607-
4608- if let Some ( identity) = identity {
4609- match identity {
4610- TruncateIdentityOption :: Restart => write ! ( f, " RESTART IDENTITY" ) ?,
4611- TruncateIdentityOption :: Continue => write ! ( f, " CONTINUE IDENTITY" ) ?,
4612- }
4613- }
4614- if let Some ( cascade) = cascade {
4615- match cascade {
4616- CascadeOption :: Cascade => write ! ( f, " CASCADE" ) ?,
4617- CascadeOption :: Restrict => write ! ( f, " RESTRICT" ) ?,
4618- }
4619- }
4620-
4621- if let Some ( ref parts) = partitions {
4622- if !parts. is_empty ( ) {
4623- write ! ( f, " PARTITION ({})" , display_comma_separated( parts) ) ?;
4624- }
4625- }
4626- if let Some ( on_cluster) = on_cluster {
4627- write ! ( f, " ON CLUSTER {on_cluster}" ) ?;
4628- }
4629- Ok ( ( ) )
4630- }
4582+ Statement :: Truncate ( truncate) => truncate. fmt ( f) ,
46314583 Statement :: Case ( stmt) => {
46324584 write ! ( f, "{stmt}" )
46334585 }
0 commit comments