@@ -70,7 +70,10 @@ pub enum AlterTableOperation {
7070 ///
7171 /// Note: this is a ClickHouse-specific operation.
7272 /// Please refer to [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/projection#drop-projection)
73- DropProjection { if_exists : bool , name : Ident } ,
73+ DropProjection {
74+ if_exists : bool ,
75+ name : Ident ,
76+ } ,
7477
7578 /// `MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition_name]`
7679 ///
@@ -99,11 +102,15 @@ pub enum AlterTableOperation {
99102 /// `DISABLE RULE rewrite_rule_name`
100103 ///
101104 /// Note: this is a PostgreSQL-specific operation.
102- DisableRule { name : Ident } ,
105+ DisableRule {
106+ name : Ident ,
107+ } ,
103108 /// `DISABLE TRIGGER [ trigger_name | ALL | USER ]`
104109 ///
105110 /// Note: this is a PostgreSQL-specific operation.
106- DisableTrigger { name : Ident } ,
111+ DisableTrigger {
112+ name : Ident ,
113+ } ,
107114 /// `DROP CONSTRAINT [ IF EXISTS ] <name>`
108115 DropConstraint {
109116 if_exists : bool ,
@@ -152,31 +159,43 @@ pub enum AlterTableOperation {
152159 /// `ENABLE ALWAYS RULE rewrite_rule_name`
153160 ///
154161 /// Note: this is a PostgreSQL-specific operation.
155- EnableAlwaysRule { name : Ident } ,
162+ EnableAlwaysRule {
163+ name : Ident ,
164+ } ,
156165 /// `ENABLE ALWAYS TRIGGER trigger_name`
157166 ///
158167 /// Note: this is a PostgreSQL-specific operation.
159- EnableAlwaysTrigger { name : Ident } ,
168+ EnableAlwaysTrigger {
169+ name : Ident ,
170+ } ,
160171 /// `ENABLE REPLICA RULE rewrite_rule_name`
161172 ///
162173 /// Note: this is a PostgreSQL-specific operation.
163- EnableReplicaRule { name : Ident } ,
174+ EnableReplicaRule {
175+ name : Ident ,
176+ } ,
164177 /// `ENABLE REPLICA TRIGGER trigger_name`
165178 ///
166179 /// Note: this is a PostgreSQL-specific operation.
167- EnableReplicaTrigger { name : Ident } ,
180+ EnableReplicaTrigger {
181+ name : Ident ,
182+ } ,
168183 /// `ENABLE ROW LEVEL SECURITY`
169184 ///
170185 /// Note: this is a PostgreSQL-specific operation.
171186 EnableRowLevelSecurity ,
172187 /// `ENABLE RULE rewrite_rule_name`
173188 ///
174189 /// Note: this is a PostgreSQL-specific operation.
175- EnableRule { name : Ident } ,
190+ EnableRule {
191+ name : Ident ,
192+ } ,
176193 /// `ENABLE TRIGGER [ trigger_name | ALL | USER ]`
177194 ///
178195 /// Note: this is a PostgreSQL-specific operation.
179- EnableTrigger { name : Ident } ,
196+ EnableTrigger {
197+ name : Ident ,
198+ } ,
180199 /// `RENAME TO PARTITION (partition=val)`
181200 RenamePartitions {
182201 old_partitions : Vec < Expr > ,
@@ -197,7 +216,9 @@ pub enum AlterTableOperation {
197216 new_column_name : Ident ,
198217 } ,
199218 /// `RENAME TO <table_name>`
200- RenameTable { table_name : ObjectName } ,
219+ RenameTable {
220+ table_name : ObjectName ,
221+ } ,
201222 // CHANGE [ COLUMN ] <old_name> <new_name> <data_type> [ <options> ]
202223 ChangeColumn {
203224 old_name : Ident ,
@@ -218,7 +239,10 @@ pub enum AlterTableOperation {
218239 /// `RENAME CONSTRAINT <old_constraint_name> TO <new_constraint_name>`
219240 ///
220241 /// Note: this is a PostgreSQL-specific operation.
221- RenameConstraint { old_name : Ident , new_name : Ident } ,
242+ RenameConstraint {
243+ old_name : Ident ,
244+ new_name : Ident ,
245+ } ,
222246 /// `ALTER [ COLUMN ]`
223247 AlterColumn {
224248 column_name : Ident ,
@@ -227,14 +251,27 @@ pub enum AlterTableOperation {
227251 /// 'SWAP WITH <table_name>'
228252 ///
229253 /// Note: this is Snowflake specific <https://docs.snowflake.com/en/sql-reference/sql/alter-table>
230- SwapWith { table_name : ObjectName } ,
254+ SwapWith {
255+ table_name : ObjectName ,
256+ } ,
231257 /// 'SET TBLPROPERTIES ( { property_key [ = ] property_val } [, ...] )'
232- SetTblProperties { table_properties : Vec < SqlOption > } ,
233-
258+ SetTblProperties {
259+ table_properties : Vec < SqlOption > ,
260+ } ,
234261 /// `OWNER TO { <new_owner> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
235262 ///
236263 /// Note: this is PostgreSQL-specific <https://www.postgresql.org/docs/current/sql-altertable.html>
237- OwnerTo { new_owner : Owner } ,
264+ OwnerTo {
265+ new_owner : Owner ,
266+ } ,
267+ /// Snowflake table clustering options
268+ /// <https://docs.snowflake.com/en/sql-reference/sql/alter-table#clustering-actions-clusteringaction>
269+ ClusterBy {
270+ exprs : Vec < Expr > ,
271+ } ,
272+ DropClusteringKey ,
273+ SuspendRecluster ,
274+ ResumeRecluster ,
238275}
239276
240277/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -548,6 +585,22 @@ impl fmt::Display for AlterTableOperation {
548585 }
549586 Ok ( ( ) )
550587 }
588+ AlterTableOperation :: ClusterBy { exprs } => {
589+ write ! ( f, "CLUSTER BY ({})" , display_comma_separated( exprs) ) ?;
590+ Ok ( ( ) )
591+ }
592+ AlterTableOperation :: DropClusteringKey => {
593+ write ! ( f, "DROP CLUSTERING KEY" ) ?;
594+ Ok ( ( ) )
595+ }
596+ AlterTableOperation :: SuspendRecluster => {
597+ write ! ( f, "SUSPEND RECLUSTER" ) ?;
598+ Ok ( ( ) )
599+ }
600+ AlterTableOperation :: ResumeRecluster => {
601+ write ! ( f, "RESUME RECLUSTER" ) ?;
602+ Ok ( ( ) )
603+ }
551604 }
552605 }
553606}
0 commit comments