@@ -33,10 +33,11 @@ use crate::ast::{
33
33
display_comma_separated, display_separated, ArgMode , CommentDef , CreateFunctionBody ,
34
34
CreateFunctionUsing , CreateTableLikeKind , CreateTableOptions , DataType , Expr , FileFormat ,
35
35
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 ,
40
41
} ;
41
42
use crate :: display_utils:: { DisplayCommaSeparated , Indent , NewLine , SpaceOrNewline } ;
42
43
use crate :: keywords:: Keyword ;
@@ -2428,6 +2429,7 @@ pub struct CreateTable {
2428
2429
pub or_replace : bool ,
2429
2430
pub temporary : bool ,
2430
2431
pub external : bool ,
2432
+ pub dynamic : bool ,
2431
2433
pub global : Option < bool > ,
2432
2434
pub if_not_exists : bool ,
2433
2435
pub transient : bool ,
@@ -2448,6 +2450,7 @@ pub struct CreateTable {
2448
2450
pub without_rowid : bool ,
2449
2451
pub like : Option < CreateTableLikeKind > ,
2450
2452
pub clone : Option < ObjectName > ,
2453
+ pub version : Option < TableVersion > ,
2451
2454
// For Hive dialect, the table comment is after the column definitions without `=`,
2452
2455
// so the `comment` field is optional and different than the comment field in the general options list.
2453
2456
// [Hive](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable)
@@ -2525,6 +2528,21 @@ pub struct CreateTable {
2525
2528
/// Snowflake "STORAGE_SERIALIZATION_POLICY" clause for Iceberg tables
2526
2529
/// <https://docs.snowflake.com/en/sql-reference/sql/create-iceberg-table>
2527
2530
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 ,
2528
2546
}
2529
2547
2530
2548
impl fmt:: Display for CreateTable {
@@ -2538,7 +2556,7 @@ impl fmt::Display for CreateTable {
2538
2556
// `CREATE TABLE t (a INT) AS SELECT a from t2`
2539
2557
write ! (
2540
2558
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}" ,
2542
2560
or_replace = if self . or_replace { "OR REPLACE " } else { "" } ,
2543
2561
external = if self . external { "EXTERNAL " } else { "" } ,
2544
2562
global = self . global
@@ -2556,6 +2574,7 @@ impl fmt::Display for CreateTable {
2556
2574
volatile = if self . volatile { "VOLATILE " } else { "" } ,
2557
2575
// Only for Snowflake
2558
2576
iceberg = if self . iceberg { "ICEBERG " } else { "" } ,
2577
+ dynamic = if self . dynamic { "DYNAMIC " } else { "" } ,
2559
2578
name = self . name,
2560
2579
) ?;
2561
2580
if let Some ( on_cluster) = & self . on_cluster {
@@ -2598,6 +2617,10 @@ impl fmt::Display for CreateTable {
2598
2617
write ! ( f, " CLONE {c}" ) ?;
2599
2618
}
2600
2619
2620
+ if let Some ( version) = & self . version {
2621
+ write ! ( f, " {version}" ) ?;
2622
+ }
2623
+
2601
2624
match & self . hive_distribution {
2602
2625
HiveDistributionStyle :: PARTITIONED { columns } => {
2603
2626
write ! ( f, " PARTITIONED BY ({})" , display_comma_separated( columns) ) ?;
@@ -2700,27 +2723,27 @@ impl fmt::Display for CreateTable {
2700
2723
write ! ( f, " {options}" ) ?;
2701
2724
}
2702
2725
if let Some ( external_volume) = self . external_volume . as_ref ( ) {
2703
- write ! ( f, " EXTERNAL_VOLUME = '{external_volume}'" ) ?;
2726
+ write ! ( f, " EXTERNAL_VOLUME= '{external_volume}'" ) ?;
2704
2727
}
2705
2728
2706
2729
if let Some ( catalog) = self . catalog . as_ref ( ) {
2707
- write ! ( f, " CATALOG = '{catalog}'" ) ?;
2730
+ write ! ( f, " CATALOG= '{catalog}'" ) ?;
2708
2731
}
2709
2732
2710
2733
if self . iceberg {
2711
2734
if let Some ( base_location) = self . base_location . as_ref ( ) {
2712
- write ! ( f, " BASE_LOCATION = '{base_location}'" ) ?;
2735
+ write ! ( f, " BASE_LOCATION= '{base_location}'" ) ?;
2713
2736
}
2714
2737
}
2715
2738
2716
2739
if let Some ( catalog_sync) = self . catalog_sync . as_ref ( ) {
2717
- write ! ( f, " CATALOG_SYNC = '{catalog_sync}'" ) ?;
2740
+ write ! ( f, " CATALOG_SYNC= '{catalog_sync}'" ) ?;
2718
2741
}
2719
2742
2720
2743
if let Some ( storage_serialization_policy) = self . storage_serialization_policy . as_ref ( ) {
2721
2744
write ! (
2722
2745
f,
2723
- " STORAGE_SERIALIZATION_POLICY = {storage_serialization_policy}"
2746
+ " STORAGE_SERIALIZATION_POLICY= {storage_serialization_policy}"
2724
2747
) ?;
2725
2748
}
2726
2749
@@ -2774,6 +2797,26 @@ impl fmt::Display for CreateTable {
2774
2797
write ! ( f, " WITH TAG ({})" , display_comma_separated( tag. as_slice( ) ) ) ?;
2775
2798
}
2776
2799
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
+
2777
2820
if self . on_commit . is_some ( ) {
2778
2821
let on_commit = match self . on_commit {
2779
2822
Some ( OnCommit :: DeleteRows ) => "ON COMMIT DELETE ROWS" ,
0 commit comments