@@ -35,22 +35,54 @@ pub enum AlterTableOperation {
3535 if_exists : bool ,
3636 cascade : bool ,
3737 } ,
38+ /// `RENAME TO PARTITION (partition=val)`
39+ RenamePartitions {
40+ old_partitions : Vec < Expr > ,
41+ new_partitions : Vec < Expr > ,
42+ } ,
43+ /// Add Partitions
44+ AddPartitions {
45+ if_not_exists : bool ,
46+ new_partitions : Vec < Expr > ,
47+ } ,
48+ DropPartitions {
49+ partitions : Vec < Expr > ,
50+ if_exists : bool ,
51+ } ,
3852 /// `RENAME [ COLUMN ] <old_column_name> TO <new_column_name>`
3953 RenameColumn {
4054 old_column_name : Ident ,
4155 new_column_name : Ident ,
4256 } ,
4357 /// `RENAME TO <table_name>`
44- RenameTable { table_name : Ident } ,
58+ RenameTable { table_name : ObjectName } ,
4559}
4660
4761impl fmt:: Display for AlterTableOperation {
4862 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4963 match self {
64+ AlterTableOperation :: AddPartitions {
65+ if_not_exists,
66+ new_partitions,
67+ } => write ! (
68+ f,
69+ "ADD{ine} PARTITION ({})" ,
70+ display_comma_separated( new_partitions) ,
71+ ine = if * if_not_exists { " IF NOT EXISTS" } else { "" }
72+ ) ,
5073 AlterTableOperation :: AddConstraint ( c) => write ! ( f, "ADD {}" , c) ,
5174 AlterTableOperation :: AddColumn { column_def } => {
5275 write ! ( f, "ADD COLUMN {}" , column_def. to_string( ) )
5376 }
77+ AlterTableOperation :: DropPartitions {
78+ partitions,
79+ if_exists,
80+ } => write ! (
81+ f,
82+ "DROP{ie} PARTITION ({})" ,
83+ display_comma_separated( partitions) ,
84+ ie = if * if_exists { " IF EXISTS" } else { "" }
85+ ) ,
5486 AlterTableOperation :: DropConstraint { name } => write ! ( f, "DROP CONSTRAINT {}" , name) ,
5587 AlterTableOperation :: DropColumn {
5688 column_name,
@@ -63,6 +95,15 @@ impl fmt::Display for AlterTableOperation {
6395 column_name,
6496 if * cascade { " CASCADE" } else { "" }
6597 ) ,
98+ AlterTableOperation :: RenamePartitions {
99+ old_partitions,
100+ new_partitions,
101+ } => write ! (
102+ f,
103+ "PARTITION ({}) RENAME TO PARTITION ({})" ,
104+ display_comma_separated( old_partitions) ,
105+ display_comma_separated( new_partitions)
106+ ) ,
66107 AlterTableOperation :: RenameColumn {
67108 old_column_name,
68109 new_column_name,
0 commit comments