@@ -26,9 +26,10 @@ use sqlparser_derive::{Visit, VisitMut};
26
26
27
27
use super :: super :: dml:: CreateTable ;
28
28
use crate :: ast:: {
29
- ClusteredBy , ColumnDef , CommentDef , Expr , FileFormat , HiveDistributionStyle , HiveFormat , Ident ,
30
- ObjectName , OnCommit , OneOrManyWithParens , Query , RowAccessPolicy , SqlOption , Statement ,
31
- StorageSerializationPolicy , TableConstraint , Tag , WrappedCollection ,
29
+ ClusteredBy , ColumnDef , CommentDef , CreateTableOptions , Expr , FileFormat ,
30
+ HiveDistributionStyle , HiveFormat , Ident , ObjectName , OnCommit , OneOrManyWithParens , Query ,
31
+ RowAccessPolicy , Statement , StorageSerializationPolicy , TableConstraint , Tag ,
32
+ WrappedCollection ,
32
33
} ;
33
34
34
35
use crate :: parser:: ParserError ;
@@ -77,10 +78,6 @@ pub struct CreateTableBuilder {
77
78
pub constraints : Vec < TableConstraint > ,
78
79
pub hive_distribution : HiveDistributionStyle ,
79
80
pub hive_formats : Option < HiveFormat > ,
80
- pub table_properties : Vec < SqlOption > ,
81
- pub with_options : Vec < SqlOption > ,
82
- pub options : Option < Vec < SqlOption > > ,
83
- pub plain_options : Vec < SqlOption > ,
84
81
pub file_format : Option < FileFormat > ,
85
82
pub location : Option < String > ,
86
83
pub query : Option < Box < Query > > ,
@@ -110,6 +107,7 @@ pub struct CreateTableBuilder {
110
107
pub catalog : Option < String > ,
111
108
pub catalog_sync : Option < String > ,
112
109
pub storage_serialization_policy : Option < StorageSerializationPolicy > ,
110
+ pub table_options : CreateTableOptions ,
113
111
}
114
112
115
113
impl CreateTableBuilder {
@@ -128,9 +126,6 @@ impl CreateTableBuilder {
128
126
constraints : vec ! [ ] ,
129
127
hive_distribution : HiveDistributionStyle :: NONE ,
130
128
hive_formats : None ,
131
- table_properties : vec ! [ ] ,
132
- plain_options : vec ! [ ] ,
133
- with_options : vec ! [ ] ,
134
129
file_format : None ,
135
130
location : None ,
136
131
query : None ,
@@ -145,7 +140,6 @@ impl CreateTableBuilder {
145
140
partition_by : None ,
146
141
cluster_by : None ,
147
142
clustered_by : None ,
148
- options : None ,
149
143
strict : false ,
150
144
copy_grants : false ,
151
145
enable_schema_evolution : None ,
@@ -161,6 +155,7 @@ impl CreateTableBuilder {
161
155
catalog : None ,
162
156
catalog_sync : None ,
163
157
storage_serialization_policy : None ,
158
+ table_options : CreateTableOptions :: None ,
164
159
}
165
160
}
166
161
pub fn or_replace ( mut self , or_replace : bool ) -> Self {
@@ -223,15 +218,6 @@ impl CreateTableBuilder {
223
218
self
224
219
}
225
220
226
- pub fn table_properties ( mut self , table_properties : Vec < SqlOption > ) -> Self {
227
- self . table_properties = table_properties;
228
- self
229
- }
230
-
231
- pub fn with_options ( mut self , with_options : Vec < SqlOption > ) -> Self {
232
- self . with_options = with_options;
233
- self
234
- }
235
221
pub fn file_format ( mut self , file_format : Option < FileFormat > ) -> Self {
236
222
self . file_format = file_format;
237
223
self
@@ -301,16 +287,6 @@ impl CreateTableBuilder {
301
287
self
302
288
}
303
289
304
- pub fn options ( mut self , options : Option < Vec < SqlOption > > ) -> Self {
305
- self . options = options;
306
- self
307
- }
308
-
309
- pub fn plain_options ( mut self , options : Vec < SqlOption > ) -> Self {
310
- self . plain_options = options;
311
- self
312
- }
313
-
314
290
pub fn strict ( mut self , strict : bool ) -> Self {
315
291
self . strict = strict;
316
292
self
@@ -395,6 +371,11 @@ impl CreateTableBuilder {
395
371
self
396
372
}
397
373
374
+ pub fn table_options ( mut self , table_options : CreateTableOptions ) -> Self {
375
+ self . table_options = table_options;
376
+ self
377
+ }
378
+
398
379
pub fn build ( self ) -> Statement {
399
380
Statement :: CreateTable ( CreateTable {
400
381
or_replace : self . or_replace ,
@@ -410,8 +391,6 @@ impl CreateTableBuilder {
410
391
constraints : self . constraints ,
411
392
hive_distribution : self . hive_distribution ,
412
393
hive_formats : self . hive_formats ,
413
- table_properties : self . table_properties ,
414
- with_options : self . with_options ,
415
394
file_format : self . file_format ,
416
395
location : self . location ,
417
396
query : self . query ,
@@ -426,7 +405,6 @@ impl CreateTableBuilder {
426
405
partition_by : self . partition_by ,
427
406
cluster_by : self . cluster_by ,
428
407
clustered_by : self . clustered_by ,
429
- options : self . options ,
430
408
strict : self . strict ,
431
409
copy_grants : self . copy_grants ,
432
410
enable_schema_evolution : self . enable_schema_evolution ,
@@ -442,7 +420,7 @@ impl CreateTableBuilder {
442
420
catalog : self . catalog ,
443
421
catalog_sync : self . catalog_sync ,
444
422
storage_serialization_policy : self . storage_serialization_policy ,
445
- plain_options : self . plain_options ,
423
+ table_options : self . table_options ,
446
424
} )
447
425
}
448
426
}
@@ -468,8 +446,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
468
446
constraints,
469
447
hive_distribution,
470
448
hive_formats,
471
- table_properties,
472
- with_options,
473
449
file_format,
474
450
location,
475
451
query,
@@ -484,7 +460,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
484
460
partition_by,
485
461
cluster_by,
486
462
clustered_by,
487
- options,
488
463
strict,
489
464
copy_grants,
490
465
enable_schema_evolution,
@@ -500,7 +475,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
500
475
catalog,
501
476
catalog_sync,
502
477
storage_serialization_policy,
503
- plain_options ,
478
+ table_options ,
504
479
} ) => Ok ( Self {
505
480
or_replace,
506
481
temporary,
@@ -513,8 +488,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
513
488
constraints,
514
489
hive_distribution,
515
490
hive_formats,
516
- table_properties,
517
- with_options,
518
491
file_format,
519
492
location,
520
493
query,
@@ -529,7 +502,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
529
502
partition_by,
530
503
cluster_by,
531
504
clustered_by,
532
- options,
533
505
strict,
534
506
iceberg,
535
507
copy_grants,
@@ -547,7 +519,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
547
519
catalog,
548
520
catalog_sync,
549
521
storage_serialization_policy,
550
- plain_options ,
522
+ table_options ,
551
523
} ) ,
552
524
_ => Err ( ParserError :: ParserError ( format ! (
553
525
"Expected create table statement, but received: {stmt}"
@@ -561,8 +533,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
561
533
pub ( crate ) struct CreateTableConfiguration {
562
534
pub partition_by : Option < Box < Expr > > ,
563
535
pub cluster_by : Option < WrappedCollection < Vec < Ident > > > ,
564
- pub options : Option < Vec < SqlOption > > ,
565
- pub plain_options : Vec < SqlOption > ,
536
+ pub table_options : CreateTableOptions ,
566
537
}
567
538
568
539
#[ cfg( test) ]
0 commit comments