@@ -33,10 +33,10 @@ use crate::ast::{
33
33
display_comma_separated, display_separated, ArgMode , CommentDef , CreateFunctionBody ,
34
34
CreateFunctionUsing , CreateTableOptions , DataType , Expr , FileFormat , FunctionBehavior ,
35
35
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 ,
40
40
} ;
41
41
use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
42
42
use crate :: keywords:: Keyword ;
@@ -2412,6 +2412,7 @@ pub struct CreateTable {
2412
2412
pub or_replace : bool ,
2413
2413
pub temporary : bool ,
2414
2414
pub external : bool ,
2415
+ pub dynamic : bool ,
2415
2416
pub global : Option < bool > ,
2416
2417
pub if_not_exists : bool ,
2417
2418
pub transient : bool ,
@@ -2432,6 +2433,7 @@ pub struct CreateTable {
2432
2433
pub without_rowid : bool ,
2433
2434
pub like : Option < ObjectName > ,
2434
2435
pub clone : Option < ObjectName > ,
2436
+ pub version : Option < TableVersion > ,
2435
2437
// For Hive dialect, the table comment is after the column definitions without `=`,
2436
2438
// so the `comment` field is optional and different than the comment field in the general options list.
2437
2439
// [Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable)
@@ -2509,6 +2511,21 @@ pub struct CreateTable {
2509
2511
/// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
2510
2512
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
2511
2513
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 ,
2512
2529
}
2513
2530
2514
2531
impl fmt:: Display for CreateTable {
@@ -2522,7 +2539,7 @@ impl fmt::Display for CreateTable {
2522
2539
// `CREATE TABLE t (a INT) AS SELECT a from t2`
2523
2540
write ! (
2524
2541
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}" ,
2526
2543
or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
2527
2544
external = if self . external { "EXTERNAL " } else { "" } ,
2528
2545
global = self . global
@@ -2540,6 +2557,7 @@ impl fmt::Display for CreateTable {
2540
2557
volatile = if self . volatile { "VOLATILE " } else { "" } ,
2541
2558
// Only for Snowflake
2542
2559
iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
2560
+ dynamic = if self . dynamic { "DYNAMIC " } else { "" } ,
2543
2561
name = self . name,
2544
2562
) ?;
2545
2563
if let Some ( on_cluster) = & self . on_cluster {
@@ -2581,6 +2599,10 @@ impl fmt::Display for CreateTable {
2581
2599
write ! ( f, " CLONE {c}" ) ?;
2582
2600
}
2583
2601
2602
+ if let Some ( version) = & self . version {
2603
+ write ! ( f, " {version}" ) ?;
2604
+ }
2605
+
2584
2606
match & self . hive_distribution {
2585
2607
HiveDistributionStyle :: PARTITIONED { columns } => {
2586
2608
write ! ( f, " PARTITIONED BY ({})" , display_comma_separated( columns) ) ?;
@@ -2683,27 +2705,27 @@ impl fmt::Display for CreateTable {
2683
2705
write ! ( f, " {options}" ) ?;
2684
2706
}
2685
2707
if let Some ( external_volume) = self . external_volume . as_ref ( ) {
2686
- write ! ( f, " EXTERNAL_VOLUME = '{external_volume}'" ) ?;
2708
+ write ! ( f, " EXTERNAL_VOLUME= '{external_volume}'" ) ?;
2687
2709
}
2688
2710
2689
2711
if let Some ( catalog) = self . catalog . as_ref ( ) {
2690
- write ! ( f, " CATALOG = '{catalog}'" ) ?;
2712
+ write ! ( f, " CATALOG= '{catalog}'" ) ?;
2691
2713
}
2692
2714
2693
2715
if self . iceberg {
2694
2716
if let Some ( base_location) = self . base_location . as_ref ( ) {
2695
- write ! ( f, " BASE_LOCATION = '{base_location}'" ) ?;
2717
+ write ! ( f, " BASE_LOCATION= '{base_location}'" ) ?;
2696
2718
}
2697
2719
}
2698
2720
2699
2721
if let Some ( catalog_sync) = self . catalog_sync . as_ref ( ) {
2700
- write ! ( f, " CATALOG_SYNC = '{catalog_sync}'" ) ?;
2722
+ write ! ( f, " CATALOG_SYNC= '{catalog_sync}'" ) ?;
2701
2723
}
2702
2724
2703
2725
if let Some ( storage_serialization_policy) = self . storage_serialization_policy . as_ref ( ) {
2704
2726
write ! (
2705
2727
f,
2706
- " STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
2728
+ " STORAGE_SERIALIZATION_POLICY= {storage_serialization_policy}"
2707
2729
) ?;
2708
2730
}
2709
2731
@@ -2757,6 +2779,26 @@ impl fmt::Display for CreateTable {
2757
2779
write ! ( f, " WITH TAG ({})" , display_comma_separated( tag. as_slice( ) ) ) ?;
2758
2780
}
2759
2781
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
+
2760
2802
if self . on_commit . is_some ( ) {
2761
2803
let on_commit = match self . on_commit {
2762
2804
Some ( OnCommit :: DeleteRows ) => "ON COMMIT DELETE ROWS" ,
0 commit comments