@@ -33,10 +33,10 @@ use crate::ast::{
3333 display_comma_separated, display_separated, ArgMode , CommentDef , CreateFunctionBody ,
3434 CreateFunctionUsing , CreateTableOptions , DataType , Expr , FileFormat , FunctionBehavior ,
3535 FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel , HiveDistributionStyle ,
36- HiveFormat , HiveIOFormat , HiveRowFormat , Ident , MySQLColumnPosition , ObjectName , OnCommit ,
37- OneOrManyWithParens , OperateFunctionArg , OrderByExpr , ProjectionSelect , Query , RowAccessPolicy ,
38- SequenceOptions , Spanned , SqlOption , StorageSerializationPolicy , Tag , Value , ValueWithSpan ,
39- WrappedCollection ,
36+ HiveFormat , HiveIOFormat , HiveRowFormat , Ident , InitializeKind , MySQLColumnPosition ,
37+ ObjectName , OnCommit , OneOrManyWithParens , OperateFunctionArg , OrderByExpr , ProjectionSelect ,
38+ Query , RefreshModeKind , RowAccessPolicy , SequenceOptions , Spanned , SqlOption ,
39+ StorageSerializationPolicy , TableVersion , Tag , Value , ValueWithSpan , WrappedCollection ,
4040} ;
4141use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
4242use crate :: keywords:: Keyword ;
@@ -2412,6 +2412,7 @@ pub struct CreateTable {
24122412 pub or_replace : bool ,
24132413 pub temporary : bool ,
24142414 pub external : bool ,
2415+ pub dynamic : bool ,
24152416 pub global : Option < bool > ,
24162417 pub if_not_exists : bool ,
24172418 pub transient : bool ,
@@ -2432,6 +2433,7 @@ pub struct CreateTable {
24322433 pub without_rowid : bool ,
24332434 pub like : Option < ObjectName > ,
24342435 pub clone : Option < ObjectName > ,
2436+ pub version : Option < TableVersion > ,
24352437 // For Hive dialect, the table comment is after the column definitions without `=`,
24362438 // so the `comment` field is optional and different than the comment field in the general options list.
24372439 // [Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable)
@@ -2509,6 +2511,21 @@ pub struct CreateTable {
25092511 /// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
25102512 /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
25112513 pub storage_serialization_policy : Option < StorageSerializationPolicy > ,
2514+ /// Snowflake "TARGET_LAG" clause for dybamic tables
2515+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2516+ pub target_lag : Option < String > ,
2517+ /// Snowflake "WAREHOUSE" clause for dybamic tables
2518+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2519+ pub warehouse : Option < Ident > ,
2520+ /// Snowflake "REFRESH_MODE" clause for dybamic tables
2521+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2522+ pub refresh_mode : Option < RefreshModeKind > ,
2523+ /// Snowflake "INITIALIZE" clause for dybamic tables
2524+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2525+ pub initialize : Option < InitializeKind > ,
2526+ /// Snowflake "REQUIRE USER" clause for dybamic tables
2527+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2528+ pub require_user : bool ,
25122529}
25132530
25142531impl fmt:: Display for CreateTable {
@@ -2522,7 +2539,7 @@ impl fmt::Display for CreateTable {
25222539 // `CREATE TABLE t (a INT) AS SELECT a from t2`
25232540 write ! (
25242541 f,
2525- "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{iceberg}TABLE {if_not_exists}{name}" ,
2542+ "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{dynamic}{ iceberg}TABLE {if_not_exists}{name}" ,
25262543 or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
25272544 external = if self . external { "EXTERNAL " } else { "" } ,
25282545 global = self . global
@@ -2540,6 +2557,7 @@ impl fmt::Display for CreateTable {
25402557 volatile = if self . volatile { "VOLATILE " } else { "" } ,
25412558 // Only for Snowflake
25422559 iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
2560+ dynamic = if self . dynamic { "DYNAMIC " } else { "" } ,
25432561 name = self . name,
25442562 ) ?;
25452563 if let Some ( on_cluster) = & self . on_cluster {
@@ -2581,6 +2599,10 @@ impl fmt::Display for CreateTable {
25812599 write ! ( f, " CLONE {c}" ) ?;
25822600 }
25832601
2602+ if let Some ( version) = & self . version {
2603+ write ! ( f, " {version}" ) ?;
2604+ }
2605+
25842606 match & self . hive_distribution {
25852607 HiveDistributionStyle :: PARTITIONED { columns } => {
25862608 write ! ( f, " PARTITIONED BY ({})" , display_comma_separated( columns) ) ?;
@@ -2683,27 +2705,27 @@ impl fmt::Display for CreateTable {
26832705 write ! ( f, " {options}" ) ?;
26842706 }
26852707 if let Some ( external_volume) = self . external_volume . as_ref ( ) {
2686- write ! ( f, " EXTERNAL_VOLUME = '{external_volume}'" ) ?;
2708+ write ! ( f, " EXTERNAL_VOLUME= '{external_volume}'" ) ?;
26872709 }
26882710
26892711 if let Some ( catalog) = self . catalog . as_ref ( ) {
2690- write ! ( f, " CATALOG = '{catalog}'" ) ?;
2712+ write ! ( f, " CATALOG= '{catalog}'" ) ?;
26912713 }
26922714
26932715 if self . iceberg {
26942716 if let Some ( base_location) = self . base_location . as_ref ( ) {
2695- write ! ( f, " BASE_LOCATION = '{base_location}'" ) ?;
2717+ write ! ( f, " BASE_LOCATION= '{base_location}'" ) ?;
26962718 }
26972719 }
26982720
26992721 if let Some ( catalog_sync) = self . catalog_sync . as_ref ( ) {
2700- write ! ( f, " CATALOG_SYNC = '{catalog_sync}'" ) ?;
2722+ write ! ( f, " CATALOG_SYNC= '{catalog_sync}'" ) ?;
27012723 }
27022724
27032725 if let Some ( storage_serialization_policy) = self . storage_serialization_policy . as_ref ( ) {
27042726 write ! (
27052727 f,
2706- " STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
2728+ " STORAGE_SERIALIZATION_POLICY= {storage_serialization_policy}"
27072729 ) ?;
27082730 }
27092731
@@ -2757,6 +2779,26 @@ impl fmt::Display for CreateTable {
27572779 write ! ( f, " WITH TAG ({})" , display_comma_separated( tag. as_slice( ) ) ) ?;
27582780 }
27592781
2782+ if let Some ( target_lag) = & self . target_lag {
2783+ write ! ( f, " TARGET_LAG='{target_lag}'" ) ?;
2784+ }
2785+
2786+ if let Some ( warehouse) = & self . warehouse {
2787+ write ! ( f, " WAREHOUSE={warehouse}" ) ?;
2788+ }
2789+
2790+ if let Some ( refresh_mode) = & self . refresh_mode {
2791+ write ! ( f, " REFRESH_MODE={refresh_mode}" ) ?;
2792+ }
2793+
2794+ if let Some ( initialize) = & self . initialize {
2795+ write ! ( f, " INITIALIZE={initialize}" ) ?;
2796+ }
2797+
2798+ if self . require_user {
2799+ write ! ( f, " REQUIRE USER" ) ?;
2800+ }
2801+
27602802 if self . on_commit . is_some ( ) {
27612803 let on_commit = match self . on_commit {
27622804 Some ( OnCommit :: DeleteRows ) => "ON COMMIT DELETE ROWS" ,
0 commit comments