@@ -33,10 +33,11 @@ use crate::ast::{
3333 display_comma_separated, display_separated, ArgMode , CommentDef , CreateFunctionBody ,
3434 CreateFunctionUsing , CreateTableLikeKind , CreateTableOptions , DataType , Expr , FileFormat ,
3535 FunctionBehavior , FunctionCalledOnNull , FunctionDeterminismSpecifier , FunctionParallel ,
36- HiveDistributionStyle , HiveFormat , HiveIOFormat , HiveRowFormat , Ident , MySQLColumnPosition ,
37- ObjectName , OnCommit , OneOrManyWithParens , OperateFunctionArg , OrderByExpr , ProjectionSelect ,
38- Query , RowAccessPolicy , SequenceOptions , Spanned , SqlOption , StorageSerializationPolicy , Tag ,
39- Value , ValueWithSpan , WrappedCollection ,
36+ HiveDistributionStyle , HiveFormat , HiveIOFormat , HiveRowFormat , Ident , InitializeKind ,
37+ MySQLColumnPosition , ObjectName , OnCommit , OneOrManyWithParens , OperateFunctionArg ,
38+ OrderByExpr , ProjectionSelect , Query , RefreshModeKind , RowAccessPolicy , SequenceOptions ,
39+ Spanned , SqlOption , StorageSerializationPolicy , TableVersion , Tag , Value , ValueWithSpan ,
40+ WrappedCollection ,
4041} ;
4142use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
4243use crate :: keywords:: Keyword ;
@@ -2428,6 +2429,7 @@ pub struct CreateTable {
24282429 pub or_replace : bool ,
24292430 pub temporary : bool ,
24302431 pub external : bool ,
2432+ pub dynamic : bool ,
24312433 pub global : Option < bool > ,
24322434 pub if_not_exists : bool ,
24332435 pub transient : bool ,
@@ -2448,6 +2450,7 @@ pub struct CreateTable {
24482450 pub without_rowid : bool ,
24492451 pub like : Option < CreateTableLikeKind > ,
24502452 pub clone : Option < ObjectName > ,
2453+ pub version : Option < TableVersion > ,
24512454 // For Hive dialect, the table comment is after the column definitions without `=`,
24522455 // so the `comment` field is optional and different than the comment field in the general options list.
24532456 // [Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable)
@@ -2525,6 +2528,21 @@ pub struct CreateTable {
25252528 /// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
25262529 /// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
25272530 pub storage_serialization_policy : Option < StorageSerializationPolicy > ,
2531+ /// Snowflake "TARGET_LAG" clause for dybamic tables
2532+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2533+ pub target_lag : Option < String > ,
2534+ /// Snowflake "WAREHOUSE" clause for dybamic tables
2535+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2536+ pub warehouse : Option < Ident > ,
2537+ /// Snowflake "REFRESH_MODE" clause for dybamic tables
2538+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2539+ pub refresh_mode : Option < RefreshModeKind > ,
2540+ /// Snowflake "INITIALIZE" clause for dybamic tables
2541+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2542+ pub initialize : Option < InitializeKind > ,
2543+ /// Snowflake "REQUIRE USER" clause for dybamic tables
2544+ /// <https://docs.snowflake.com/en/sql-reference/sql/create-dynamic-table>
2545+ pub require_user : bool ,
25282546}
25292547
25302548impl fmt:: Display for CreateTable {
@@ -2538,7 +2556,7 @@ impl fmt::Display for CreateTable {
25382556 // `CREATE TABLE t (a INT) AS SELECT a from t2`
25392557 write ! (
25402558 f,
2541- "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{iceberg}TABLE {if_not_exists}{name}" ,
2559+ "CREATE {or_replace}{external}{global}{temporary}{transient}{volatile}{dynamic}{ iceberg}TABLE {if_not_exists}{name}" ,
25422560 or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
25432561 external = if self . external { "EXTERNAL " } else { "" } ,
25442562 global = self . global
@@ -2556,6 +2574,7 @@ impl fmt::Display for CreateTable {
25562574 volatile = if self . volatile { "VOLATILE " } else { "" } ,
25572575 // Only for Snowflake
25582576 iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
2577+ dynamic = if self . dynamic { "DYNAMIC " } else { "" } ,
25592578 name = self . name,
25602579 ) ?;
25612580 if let Some ( on_cluster) = & self . on_cluster {
@@ -2598,6 +2617,10 @@ impl fmt::Display for CreateTable {
25982617 write ! ( f, " CLONE {c}" ) ?;
25992618 }
26002619
2620+ if let Some ( version) = & self . version {
2621+ write ! ( f, " {version}" ) ?;
2622+ }
2623+
26012624 match & self . hive_distribution {
26022625 HiveDistributionStyle :: PARTITIONED { columns } => {
26032626 write ! ( f, " PARTITIONED BY ({})" , display_comma_separated( columns) ) ?;
@@ -2700,27 +2723,27 @@ impl fmt::Display for CreateTable {
27002723 write ! ( f, " {options}" ) ?;
27012724 }
27022725 if let Some ( external_volume) = self . external_volume . as_ref ( ) {
2703- write ! ( f, " EXTERNAL_VOLUME = '{external_volume}'" ) ?;
2726+ write ! ( f, " EXTERNAL_VOLUME= '{external_volume}'" ) ?;
27042727 }
27052728
27062729 if let Some ( catalog) = self . catalog . as_ref ( ) {
2707- write ! ( f, " CATALOG = '{catalog}'" ) ?;
2730+ write ! ( f, " CATALOG= '{catalog}'" ) ?;
27082731 }
27092732
27102733 if self . iceberg {
27112734 if let Some ( base_location) = self . base_location . as_ref ( ) {
2712- write ! ( f, " BASE_LOCATION = '{base_location}'" ) ?;
2735+ write ! ( f, " BASE_LOCATION= '{base_location}'" ) ?;
27132736 }
27142737 }
27152738
27162739 if let Some ( catalog_sync) = self . catalog_sync . as_ref ( ) {
2717- write ! ( f, " CATALOG_SYNC = '{catalog_sync}'" ) ?;
2740+ write ! ( f, " CATALOG_SYNC= '{catalog_sync}'" ) ?;
27182741 }
27192742
27202743 if let Some ( storage_serialization_policy) = self . storage_serialization_policy . as_ref ( ) {
27212744 write ! (
27222745 f,
2723- " STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
2746+ " STORAGE_SERIALIZATION_POLICY= {storage_serialization_policy}"
27242747 ) ?;
27252748 }
27262749
@@ -2774,6 +2797,26 @@ impl fmt::Display for CreateTable {
27742797 write ! ( f, " WITH TAG ({})" , display_comma_separated( tag. as_slice( ) ) ) ?;
27752798 }
27762799
2800+ if let Some ( target_lag) = & self . target_lag {
2801+ write ! ( f, " TARGET_LAG='{target_lag}'" ) ?;
2802+ }
2803+
2804+ if let Some ( warehouse) = & self . warehouse {
2805+ write ! ( f, " WAREHOUSE={warehouse}" ) ?;
2806+ }
2807+
2808+ if let Some ( refresh_mode) = & self . refresh_mode {
2809+ write ! ( f, " REFRESH_MODE={refresh_mode}" ) ?;
2810+ }
2811+
2812+ if let Some ( initialize) = & self . initialize {
2813+ write ! ( f, " INITIALIZE={initialize}" ) ?;
2814+ }
2815+
2816+ if self . require_user {
2817+ write ! ( f, " REQUIRE USER" ) ?;
2818+ }
2819+
27772820 if self . on_commit . is_some ( ) {
27782821 let on_commit = match self . on_commit {
27792822 Some ( OnCommit :: DeleteRows ) => "ON COMMIT DELETE ROWS" ,
0 commit comments