@@ -70,7 +70,10 @@ pub enum AlterTableOperation {
70
70
///
71
71
/// Note: this is a ClickHouse-specific operation.
72
72
/// 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
+ } ,
74
77
75
78
/// `MATERIALIZE PROJECTION [IF EXISTS] name [IN PARTITION partition_name]`
76
79
///
@@ -99,11 +102,15 @@ pub enum AlterTableOperation {
99
102
/// `DISABLE RULE rewrite_rule_name`
100
103
///
101
104
/// Note: this is a PostgreSQL-specific operation.
102
- DisableRule { name : Ident } ,
105
+ DisableRule {
106
+ name : Ident ,
107
+ } ,
103
108
/// `DISABLE TRIGGER [ trigger_name | ALL | USER ]`
104
109
///
105
110
/// Note: this is a PostgreSQL-specific operation.
106
- DisableTrigger { name : Ident } ,
111
+ DisableTrigger {
112
+ name : Ident ,
113
+ } ,
107
114
/// `DROP CONSTRAINT [ IF EXISTS ] <name>`
108
115
DropConstraint {
109
116
if_exists : bool ,
@@ -152,31 +159,43 @@ pub enum AlterTableOperation {
152
159
/// `ENABLE ALWAYS RULE rewrite_rule_name`
153
160
///
154
161
/// Note: this is a PostgreSQL-specific operation.
155
- EnableAlwaysRule { name : Ident } ,
162
+ EnableAlwaysRule {
163
+ name : Ident ,
164
+ } ,
156
165
/// `ENABLE ALWAYS TRIGGER trigger_name`
157
166
///
158
167
/// Note: this is a PostgreSQL-specific operation.
159
- EnableAlwaysTrigger { name : Ident } ,
168
+ EnableAlwaysTrigger {
169
+ name : Ident ,
170
+ } ,
160
171
/// `ENABLE REPLICA RULE rewrite_rule_name`
161
172
///
162
173
/// Note: this is a PostgreSQL-specific operation.
163
- EnableReplicaRule { name : Ident } ,
174
+ EnableReplicaRule {
175
+ name : Ident ,
176
+ } ,
164
177
/// `ENABLE REPLICA TRIGGER trigger_name`
165
178
///
166
179
/// Note: this is a PostgreSQL-specific operation.
167
- EnableReplicaTrigger { name : Ident } ,
180
+ EnableReplicaTrigger {
181
+ name : Ident ,
182
+ } ,
168
183
/// `ENABLE ROW LEVEL SECURITY`
169
184
///
170
185
/// Note: this is a PostgreSQL-specific operation.
171
186
EnableRowLevelSecurity ,
172
187
/// `ENABLE RULE rewrite_rule_name`
173
188
///
174
189
/// Note: this is a PostgreSQL-specific operation.
175
- EnableRule { name : Ident } ,
190
+ EnableRule {
191
+ name : Ident ,
192
+ } ,
176
193
/// `ENABLE TRIGGER [ trigger_name | ALL | USER ]`
177
194
///
178
195
/// Note: this is a PostgreSQL-specific operation.
179
- EnableTrigger { name : Ident } ,
196
+ EnableTrigger {
197
+ name : Ident ,
198
+ } ,
180
199
/// `RENAME TO PARTITION (partition=val)`
181
200
RenamePartitions {
182
201
old_partitions : Vec < Expr > ,
@@ -197,7 +216,9 @@ pub enum AlterTableOperation {
197
216
new_column_name : Ident ,
198
217
} ,
199
218
/// `RENAME TO <table_name>`
200
- RenameTable { table_name : ObjectName } ,
219
+ RenameTable {
220
+ table_name : ObjectName ,
221
+ } ,
201
222
// CHANGE [ COLUMN ] <old_name> <new_name> <data_type> [ <options> ]
202
223
ChangeColumn {
203
224
old_name : Ident ,
@@ -218,7 +239,10 @@ pub enum AlterTableOperation {
218
239
/// `RENAME CONSTRAINT <old_constraint_name> TO <new_constraint_name>`
219
240
///
220
241
/// 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
+ } ,
222
246
/// `ALTER [ COLUMN ]`
223
247
AlterColumn {
224
248
column_name : Ident ,
@@ -227,14 +251,27 @@ pub enum AlterTableOperation {
227
251
/// 'SWAP WITH <table_name>'
228
252
///
229
253
/// 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
+ } ,
231
257
/// 'SET TBLPROPERTIES ( { property_key [ = ] property_val } [, ...] )'
232
- SetTblProperties { table_properties : Vec < SqlOption > } ,
233
-
258
+ SetTblProperties {
259
+ table_properties : Vec < SqlOption > ,
260
+ } ,
234
261
/// `OWNER TO { <new_owner> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }`
235
262
///
236
263
/// 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 ,
238
275
}
239
276
240
277
/// An `ALTER Policy` (`Statement::AlterPolicy`) operation
@@ -548,6 +585,22 @@ impl fmt::Display for AlterTableOperation {
548
585
}
549
586
Ok ( ( ) )
550
587
}
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
+ }
551
604
}
552
605
}
553
606
}
0 commit comments