@@ -25,10 +25,11 @@ use serde::{Deserialize, Serialize};
2525use sqlparser_derive:: { Visit , VisitMut } ;
2626
2727use crate :: ast:: {
28- ClusteredBy , ColumnDef , CommentDef , CreateTable , CreateTableLikeKind , CreateTableOptions , Expr ,
29- FileFormat , ForValues , HiveDistributionStyle , HiveFormat , Ident , InitializeKind , ObjectName ,
30- OnCommit , OneOrManyWithParens , Query , RefreshModeKind , RowAccessPolicy , Statement ,
31- StorageSerializationPolicy , TableConstraint , TableVersion , Tag , WrappedCollection ,
28+ ClusteredBy , ColumnDef , CommentDef , CreateTable , CreateTableLikeKind , CreateTableOptions ,
29+ DistStyle , Expr , FileFormat , ForValues , HiveDistributionStyle , HiveFormat , Ident ,
30+ InitializeKind , ObjectName , OnCommit , OneOrManyWithParens , Query , RefreshModeKind ,
31+ RowAccessPolicy , Statement , StorageSerializationPolicy , TableConstraint , TableVersion , Tag ,
32+ WrappedCollection ,
3233} ;
3334
3435use crate :: parser:: ParserError ;
@@ -170,6 +171,10 @@ pub struct CreateTableBuilder {
170171 pub initialize : Option < InitializeKind > ,
171172 /// Whether operations require a user identity.
172173 pub require_user : bool ,
174+ /// Redshift `DISTSTYLE` option.
175+ pub diststyle : Option < DistStyle > ,
176+ /// Redshift `DISTKEY` option.
177+ pub distkey : Option < Ident > ,
173178}
174179
175180impl CreateTableBuilder {
@@ -229,6 +234,8 @@ impl CreateTableBuilder {
229234 refresh_mode : None ,
230235 initialize : None ,
231236 require_user : false ,
237+ diststyle : None ,
238+ distkey : None ,
232239 }
233240 }
234241 /// Set `OR REPLACE` for the CREATE TABLE statement.
@@ -504,6 +511,16 @@ impl CreateTableBuilder {
504511 self . require_user = require_user;
505512 self
506513 }
514+ /// Set Redshift `DISTSTYLE` option.
515+ pub fn diststyle ( mut self , diststyle : Option < DistStyle > ) -> Self {
516+ self . diststyle = diststyle;
517+ self
518+ }
519+ /// Set Redshift `DISTKEY` option.
520+ pub fn distkey ( mut self , distkey : Option < Ident > ) -> Self {
521+ self . distkey = distkey;
522+ self
523+ }
507524 /// Consume the builder and produce a `CreateTable`.
508525 pub fn build ( self ) -> CreateTable {
509526 CreateTable {
@@ -560,6 +577,8 @@ impl CreateTableBuilder {
560577 refresh_mode : self . refresh_mode ,
561578 initialize : self . initialize ,
562579 require_user : self . require_user ,
580+ diststyle : self . diststyle ,
581+ distkey : self . distkey ,
563582 }
564583 }
565584}
@@ -635,6 +654,8 @@ impl From<CreateTable> for CreateTableBuilder {
635654 refresh_mode : table. refresh_mode ,
636655 initialize : table. initialize ,
637656 require_user : table. require_user ,
657+ diststyle : table. diststyle ,
658+ distkey : table. distkey ,
638659 }
639660 }
640661}
0 commit comments