@@ -36,6 +36,8 @@ use crate::ast::{
36
36
use crate :: keywords:: Keyword ;
37
37
use crate :: tokenizer:: Token ;
38
38
39
+ use super :: Assignment ;
40
+
39
41
/// An `ALTER TABLE` (`Statement::AlterTable`) operation
40
42
#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
41
43
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
@@ -143,6 +145,17 @@ pub enum AlterTableOperation {
143
145
partition : Partition ,
144
146
with_name : Option < Ident > ,
145
147
} ,
148
+ /// `UPDATE <column> = <expression> [, ...] [IN PARTITION partition_id] WHERE <filter_expr>`
149
+ /// Note: this is a ClickHouse-specific operation, please refer to
150
+ /// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/alter/update)
151
+ UpdateData {
152
+ /// Column assignments
153
+ assignments : Vec < Assignment > ,
154
+ /// PARTITION
155
+ partition_id : Option < Ident > ,
156
+ /// WHERE
157
+ selection : Option < Expr > ,
158
+ } ,
146
159
/// `DROP PRIMARY KEY`
147
160
///
148
161
/// Note: this is a MySQL-specific operation.
@@ -546,6 +559,16 @@ impl fmt::Display for AlterTableOperation {
546
559
}
547
560
Ok ( ( ) )
548
561
}
562
+ AlterTableOperation :: UpdateData { assignments, partition_id, selection } => {
563
+ write ! ( f, "UPDATE {}" , display_comma_separated( assignments) ) ?;
564
+ if let Some ( partition_id) = partition_id {
565
+ write ! ( f, " IN PARTITION {}" , partition_id) ?;
566
+ }
567
+ if let Some ( selection) = selection {
568
+ write ! ( f, " WHERE {}" , selection) ?;
569
+ }
570
+ Ok ( ( ) )
571
+ }
549
572
}
550
573
}
551
574
}
0 commit comments