@@ -26,9 +26,10 @@ use sqlparser_derive::{Visit, VisitMut};
2626
2727use super :: super :: dml:: CreateTable ;
2828use 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 ,
3233} ;
3334
3435use crate :: parser:: ParserError ;
@@ -77,10 +78,6 @@ pub struct CreateTableBuilder {
7778 pub constraints : Vec < TableConstraint > ,
7879 pub hive_distribution : HiveDistributionStyle ,
7980 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 > ,
8481 pub file_format : Option < FileFormat > ,
8582 pub location : Option < String > ,
8683 pub query : Option < Box < Query > > ,
@@ -110,6 +107,7 @@ pub struct CreateTableBuilder {
110107 pub catalog : Option < String > ,
111108 pub catalog_sync : Option < String > ,
112109 pub storage_serialization_policy : Option < StorageSerializationPolicy > ,
110+ pub table_options : CreateTableOptions ,
113111}
114112
115113impl CreateTableBuilder {
@@ -128,9 +126,6 @@ impl CreateTableBuilder {
128126 constraints : vec ! [ ] ,
129127 hive_distribution : HiveDistributionStyle :: NONE ,
130128 hive_formats : None ,
131- table_properties : vec ! [ ] ,
132- plain_options : vec ! [ ] ,
133- with_options : vec ! [ ] ,
134129 file_format : None ,
135130 location : None ,
136131 query : None ,
@@ -145,7 +140,6 @@ impl CreateTableBuilder {
145140 partition_by : None ,
146141 cluster_by : None ,
147142 clustered_by : None ,
148- options : None ,
149143 strict : false ,
150144 copy_grants : false ,
151145 enable_schema_evolution : None ,
@@ -161,6 +155,7 @@ impl CreateTableBuilder {
161155 catalog : None ,
162156 catalog_sync : None ,
163157 storage_serialization_policy : None ,
158+ table_options : CreateTableOptions :: None ,
164159 }
165160 }
166161 pub fn or_replace ( mut self , or_replace : bool ) -> Self {
@@ -223,15 +218,6 @@ impl CreateTableBuilder {
223218 self
224219 }
225220
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- }
235221 pub fn file_format ( mut self , file_format : Option < FileFormat > ) -> Self {
236222 self . file_format = file_format;
237223 self
@@ -301,16 +287,6 @@ impl CreateTableBuilder {
301287 self
302288 }
303289
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-
314290 pub fn strict ( mut self , strict : bool ) -> Self {
315291 self . strict = strict;
316292 self
@@ -395,6 +371,11 @@ impl CreateTableBuilder {
395371 self
396372 }
397373
374+ pub fn table_options ( mut self , table_options : CreateTableOptions ) -> Self {
375+ self . table_options = table_options;
376+ self
377+ }
378+
398379 pub fn build ( self ) -> Statement {
399380 Statement :: CreateTable ( CreateTable {
400381 or_replace : self . or_replace ,
@@ -410,8 +391,6 @@ impl CreateTableBuilder {
410391 constraints : self . constraints ,
411392 hive_distribution : self . hive_distribution ,
412393 hive_formats : self . hive_formats ,
413- table_properties : self . table_properties ,
414- with_options : self . with_options ,
415394 file_format : self . file_format ,
416395 location : self . location ,
417396 query : self . query ,
@@ -426,7 +405,6 @@ impl CreateTableBuilder {
426405 partition_by : self . partition_by ,
427406 cluster_by : self . cluster_by ,
428407 clustered_by : self . clustered_by ,
429- options : self . options ,
430408 strict : self . strict ,
431409 copy_grants : self . copy_grants ,
432410 enable_schema_evolution : self . enable_schema_evolution ,
@@ -442,7 +420,7 @@ impl CreateTableBuilder {
442420 catalog : self . catalog ,
443421 catalog_sync : self . catalog_sync ,
444422 storage_serialization_policy : self . storage_serialization_policy ,
445- plain_options : self . plain_options ,
423+ table_options : self . table_options ,
446424 } )
447425 }
448426}
@@ -468,8 +446,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
468446 constraints,
469447 hive_distribution,
470448 hive_formats,
471- table_properties,
472- with_options,
473449 file_format,
474450 location,
475451 query,
@@ -484,7 +460,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
484460 partition_by,
485461 cluster_by,
486462 clustered_by,
487- options,
488463 strict,
489464 copy_grants,
490465 enable_schema_evolution,
@@ -500,7 +475,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
500475 catalog,
501476 catalog_sync,
502477 storage_serialization_policy,
503- plain_options ,
478+ table_options ,
504479 } ) => Ok ( Self {
505480 or_replace,
506481 temporary,
@@ -513,8 +488,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
513488 constraints,
514489 hive_distribution,
515490 hive_formats,
516- table_properties,
517- with_options,
518491 file_format,
519492 location,
520493 query,
@@ -529,7 +502,6 @@ impl TryFrom<Statement> for CreateTableBuilder {
529502 partition_by,
530503 cluster_by,
531504 clustered_by,
532- options,
533505 strict,
534506 iceberg,
535507 copy_grants,
@@ -547,7 +519,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
547519 catalog,
548520 catalog_sync,
549521 storage_serialization_policy,
550- plain_options ,
522+ table_options ,
551523 } ) ,
552524 _ => Err ( ParserError :: ParserError ( format ! (
553525 "Expected create table statement, but received: {stmt}"
@@ -561,8 +533,7 @@ impl TryFrom<Statement> for CreateTableBuilder {
561533pub ( crate ) struct CreateTableConfiguration {
562534 pub partition_by : Option < Box < Expr > > ,
563535 pub cluster_by : Option < WrappedCollection < Vec < Ident > > > ,
564- pub options : Option < Vec < SqlOption > > ,
565- pub plain_options : Vec < SqlOption > ,
536+ pub table_options : CreateTableOptions ,
566537}
567538
568539#[ cfg( test) ]
0 commit comments