@@ -10,7 +10,7 @@ use sqlparser_derive::{Visit, VisitMut};
10
10
use super :: super :: dml:: CreateTable ;
11
11
use crate :: ast:: {
12
12
ColumnDef , Expr , FileFormat , HiveDistributionStyle , HiveFormat , Ident , ObjectName , OnCommit ,
13
- Query , SqlOption , Statement , TableConstraint ,
13
+ OneOrManyWithParens , Query , SqlOption , Statement , TableConstraint , TableEngine ,
14
14
} ;
15
15
use crate :: parser:: ParserError ;
16
16
@@ -65,14 +65,15 @@ pub struct CreateTableBuilder {
65
65
pub without_rowid : bool ,
66
66
pub like : Option < ObjectName > ,
67
67
pub clone : Option < ObjectName > ,
68
- pub engine : Option < String > ,
68
+ pub engine : Option < TableEngine > ,
69
69
pub comment : Option < String > ,
70
70
pub auto_increment_offset : Option < u32 > ,
71
71
pub default_charset : Option < String > ,
72
72
pub collation : Option < String > ,
73
73
pub on_commit : Option < OnCommit > ,
74
74
pub on_cluster : Option < String > ,
75
- pub order_by : Option < Vec < Ident > > ,
75
+ pub primary_key : Option < Box < Expr > > ,
76
+ pub order_by : Option < OneOrManyWithParens < Expr > > ,
76
77
pub partition_by : Option < Box < Expr > > ,
77
78
pub cluster_by : Option < Vec < Ident > > ,
78
79
pub options : Option < Vec < SqlOption > > ,
@@ -108,6 +109,7 @@ impl CreateTableBuilder {
108
109
collation : None ,
109
110
on_commit : None ,
110
111
on_cluster : None ,
112
+ primary_key : None ,
111
113
order_by : None ,
112
114
partition_by : None ,
113
115
cluster_by : None ,
@@ -203,7 +205,7 @@ impl CreateTableBuilder {
203
205
self
204
206
}
205
207
206
- pub fn engine ( mut self , engine : Option < String > ) -> Self {
208
+ pub fn engine ( mut self , engine : Option < TableEngine > ) -> Self {
207
209
self . engine = engine;
208
210
self
209
211
}
@@ -238,7 +240,12 @@ impl CreateTableBuilder {
238
240
self
239
241
}
240
242
241
- pub fn order_by ( mut self , order_by : Option < Vec < Ident > > ) -> Self {
243
+ pub fn primary_key ( mut self , primary_key : Option < Box < Expr > > ) -> Self {
244
+ self . primary_key = primary_key;
245
+ self
246
+ }
247
+
248
+ pub fn order_by ( mut self , order_by : Option < OneOrManyWithParens < Expr > > ) -> Self {
242
249
self . order_by = order_by;
243
250
self
244
251
}
@@ -291,6 +298,7 @@ impl CreateTableBuilder {
291
298
collation : self . collation ,
292
299
on_commit : self . on_commit ,
293
300
on_cluster : self . on_cluster ,
301
+ primary_key : self . primary_key ,
294
302
order_by : self . order_by ,
295
303
partition_by : self . partition_by ,
296
304
cluster_by : self . cluster_by ,
@@ -334,6 +342,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
334
342
collation,
335
343
on_commit,
336
344
on_cluster,
345
+ primary_key,
337
346
order_by,
338
347
partition_by,
339
348
cluster_by,
@@ -366,6 +375,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
366
375
collation,
367
376
on_commit,
368
377
on_cluster,
378
+ primary_key,
369
379
order_by,
370
380
partition_by,
371
381
cluster_by,
0 commit comments