@@ -32,11 +32,12 @@ use sqlparser_derive::{Visit, VisitMut};
3232pub use super :: ddl:: { ColumnDef , TableConstraint } ;
3333
3434use super :: {
35- display_comma_separated, display_separated, ClusteredBy , CommentDef , Expr , FileFormat ,
36- FromTable , HiveDistributionStyle , HiveFormat , HiveIOFormat , HiveRowFormat , Ident ,
37- InsertAliases , MysqlInsertPriority , ObjectName , OnCommit , OnInsert , OneOrManyWithParens ,
38- OrderByExpr , Query , RowAccessPolicy , SelectItem , SqlOption , SqliteOnConflict , TableEngine ,
39- TableWithJoins , Tag , WrappedCollection ,
35+ display_comma_separated, display_separated, query:: InputFormatClause , Assignment , ClusteredBy ,
36+ CommentDef , Expr , FileFormat , FromTable , HiveDistributionStyle , HiveFormat , HiveIOFormat ,
37+ HiveRowFormat , Ident , InsertAliases , MysqlInsertPriority , ObjectName , OnCommit , OnInsert ,
38+ OneOrManyWithParens , OrderByExpr , Query , RowAccessPolicy , SelectItem , Setting , SqlOption ,
39+ SqliteOnConflict , StorageSerializationPolicy , TableEngine , TableObject , TableWithJoins , Tag ,
40+ WrappedCollection ,
4041} ;
4142
4243/// CREATE INDEX statement.
@@ -117,6 +118,7 @@ pub struct CreateTable {
117118 pub if_not_exists : bool ,
118119 pub transient : bool ,
119120 pub volatile : bool ,
121+ pub iceberg : bool ,
120122 /// Table name
121123 #[ cfg_attr( feature = "visitor" , visit( with = "visit_relation" ) ) ]
122124 pub name : ObjectName ,
@@ -192,6 +194,21 @@ pub struct CreateTable {
192194 /// Snowflake "WITH TAG" clause
193195 /// <https://docs.snowflake.com/en/sql-reference/sql/create-table>
194196 pub with_tags : Option < Vec < Tag > > ,
197+ /// Snowflake "EXTERNAL_VOLUME" clause for Iceberg tables
198+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
199+ pub external_volume : Option < String > ,
200+ /// Snowflake "BASE_LOCATION" clause for Iceberg tables
201+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
202+ pub base_location : Option < String > ,
203+ /// Snowflake "CATALOG" clause for Iceberg tables
204+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
205+ pub catalog : Option < String > ,
206+ /// Snowflake "CATALOG_SYNC" clause for Iceberg tables
207+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
208+ pub catalog_sync : Option < String > ,
209+ /// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
210+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
211+ pub storage_serialization_policy : Option < StorageSerializationPolicy > ,
195212}
196213
197214impl Display for CreateTable {
@@ -205,7 +222,7 @@ impl Display for CreateTable {
205222 // `CREATE TABLE t (a INT) AS SELECT a from t2`
206223 write ! (
207224 f,
208- "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}TABLE {if_not_exists}{name}" ,
225+ "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{iceberg} TABLE {if_not_exists}{name}" ,
209226 or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
210227 external = if self . external { "EXTERNAL " } else { "" } ,
211228 global = self . global
@@ -221,6 +238,8 @@ impl Display for CreateTable {
221238 temporary = if self . temporary { "TEMPORARY " } else { "" } ,
222239 transient = if self . transient { "TRANSIENT " } else { "" } ,
223240 volatile = if self . volatile { "VOLATILE " } else { "" } ,
241+ // Only for Snowflake
242+ iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
224243 name = self . name,
225244 ) ?;
226245 if let Some ( on_cluster) = & self . on_cluster {
@@ -382,6 +401,31 @@ impl Display for CreateTable {
382401 ) ?;
383402 }
384403
404+ if let Some ( external_volume) = self . external_volume . as_ref ( ) {
405+ write ! ( f, " EXTERNAL_VOLUME = '{external_volume}'" ) ?;
406+ }
407+
408+ if let Some ( catalog) = self . catalog . as_ref ( ) {
409+ write ! ( f, " CATALOG = '{catalog}'" ) ?;
410+ }
411+
412+ if self . iceberg {
413+ if let Some ( base_location) = self . base_location . as_ref ( ) {
414+ write ! ( f, " BASE_LOCATION = '{base_location}'" ) ?;
415+ }
416+ }
417+
418+ if let Some ( catalog_sync) = self . catalog_sync . as_ref ( ) {
419+ write ! ( f, " CATALOG_SYNC = '{catalog_sync}'" ) ?;
420+ }
421+
422+ if let Some ( storage_serialization_policy) = self . storage_serialization_policy . as_ref ( ) {
423+ write ! (
424+ f,
425+ " STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
426+ ) ?;
427+ }
428+
385429 if self . copy_grants {
386430 write ! ( f, " COPY GRANTS" ) ?;
387431 }
0 commit comments