@@ -35,22 +35,54 @@ pub enum AlterTableOperation {
35
35
if_exists : bool ,
36
36
cascade : bool ,
37
37
} ,
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
+ } ,
38
52
/// `RENAME [ COLUMN ] <old_column_name> TO <new_column_name>`
39
53
RenameColumn {
40
54
old_column_name : Ident ,
41
55
new_column_name : Ident ,
42
56
} ,
43
57
/// `RENAME TO <table_name>`
44
- RenameTable { table_name : Ident } ,
58
+ RenameTable { table_name : ObjectName } ,
45
59
}
46
60
47
61
impl fmt:: Display for AlterTableOperation {
48
62
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
49
63
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
+ ) ,
50
73
AlterTableOperation :: AddConstraint ( c) => write ! ( f, "ADD {}" , c) ,
51
74
AlterTableOperation :: AddColumn { column_def } => {
52
75
write ! ( f, "ADD COLUMN {}" , column_def. to_string( ) )
53
76
}
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
+ ) ,
54
86
AlterTableOperation :: DropConstraint { name } => write ! ( f, "DROP CONSTRAINT {}" , name) ,
55
87
AlterTableOperation :: DropColumn {
56
88
column_name,
@@ -63,6 +95,15 @@ impl fmt::Display for AlterTableOperation {
63
95
column_name,
64
96
if * cascade { " CASCADE" } else { "" }
65
97
) ,
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
+ ) ,
66
107
AlterTableOperation :: RenameColumn {
67
108
old_column_name,
68
109
new_column_name,
0 commit comments