@@ -32,11 +32,12 @@ use sqlparser_derive::{Visit, VisitMut};
32
32
pub use super :: ddl:: { ColumnDef , TableConstraint } ;
33
33
34
34
use 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 ,
40
41
} ;
41
42
42
43
/// CREATE INDEX statement.
@@ -117,6 +118,7 @@ pub struct CreateTable {
117
118
pub if_not_exists : bool ,
118
119
pub transient : bool ,
119
120
pub volatile : bool ,
121
+ pub iceberg : bool ,
120
122
/// Table name
121
123
#[ cfg_attr( feature = "visitor" , visit( with = "visit_relation" ) ) ]
122
124
pub name : ObjectName ,
@@ -192,6 +194,21 @@ pub struct CreateTable {
192
194
/// Snowflake "WITH TAG" clause
193
195
/// <https://docs.snowflake.com/en/sql-reference/sql/create-table>
194
196
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 > ,
195
212
}
196
213
197
214
impl Display for CreateTable {
@@ -205,7 +222,7 @@ impl Display for CreateTable {
205
222
// `CREATE TABLE t (a INT) AS SELECT a from t2`
206
223
write ! (
207
224
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}" ,
209
226
or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
210
227
external = if self . external { "EXTERNAL " } else { "" } ,
211
228
global = self . global
@@ -221,6 +238,8 @@ impl Display for CreateTable {
221
238
temporary = if self . temporary { "TEMPORARY " } else { "" } ,
222
239
transient = if self . transient { "TRANSIENT " } else { "" } ,
223
240
volatile = if self . volatile { "VOLATILE " } else { "" } ,
241
+ // Only for Snowflake
242
+ iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
224
243
name = self . name,
225
244
) ?;
226
245
if let Some ( on_cluster) = & self . on_cluster {
@@ -382,6 +401,31 @@ impl Display for CreateTable {
382
401
) ?;
383
402
}
384
403
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
+
385
429
if self . copy_grants {
386
430
write ! ( f, " COPY GRANTS" ) ?;
387
431
}
0 commit comments