@@ -1051,6 +1051,120 @@ fn test_snowflake_create_iceberg_table_without_location() {
10511051 ) ;
10521052}
10531053
1054+ #[ test]
1055+ fn test_snowflake_create_iceberg_table_comma_separated_options ( ) {
1056+ let canonical = "CREATE ICEBERG TABLE my_table (a INT) \
1057+ EXTERNAL_VOLUME='volume' CATALOG='SNOWFLAKE' BASE_LOCATION='relative/path'";
1058+ let with_commas = "CREATE ICEBERG TABLE my_table (a INT) \
1059+ CATALOG='SNOWFLAKE', EXTERNAL_VOLUME='volume', BASE_LOCATION='relative/path'";
1060+ match snowflake ( ) . one_statement_parses_to ( with_commas, canonical) {
1061+ Statement :: CreateTable ( CreateTable {
1062+ iceberg,
1063+ columns,
1064+ external_volume,
1065+ catalog,
1066+ base_location,
1067+ ..
1068+ } ) => {
1069+ assert ! ( iceberg) ;
1070+ assert_eq ! ( 1 , columns. len( ) ) ;
1071+ assert_eq ! ( "volume" , external_volume. unwrap( ) ) ;
1072+ assert_eq ! ( "SNOWFLAKE" , catalog. unwrap( ) ) ;
1073+ assert_eq ! ( "relative/path" , base_location. unwrap( ) ) ;
1074+ }
1075+ _ => unreachable ! ( ) ,
1076+ }
1077+ }
1078+
1079+ #[ test]
1080+ fn test_snowflake_create_iceberg_table_externally_managed ( ) {
1081+ match snowflake ( ) . verified_stmt (
1082+ "CREATE OR REPLACE ICEBERG TABLE my_table \
1083+ CATALOG='my_catalog_integration' CATALOG_TABLE_NAME='db.tbl' AUTO_REFRESH=TRUE",
1084+ ) {
1085+ Statement :: CreateTable ( CreateTable {
1086+ or_replace,
1087+ iceberg,
1088+ columns,
1089+ catalog,
1090+ catalog_table_name,
1091+ auto_refresh,
1092+ base_location,
1093+ query,
1094+ ..
1095+ } ) => {
1096+ assert ! ( or_replace) ;
1097+ assert ! ( iceberg) ;
1098+ assert ! ( columns. is_empty( ) ) ;
1099+ assert_eq ! ( "my_catalog_integration" , catalog. unwrap( ) ) ;
1100+ assert_eq ! ( "db.tbl" , catalog_table_name. unwrap( ) ) ;
1101+ assert_eq ! ( Some ( true ) , auto_refresh) ;
1102+ assert ! ( base_location. is_none( ) ) ;
1103+ assert ! ( query. is_none( ) ) ;
1104+ }
1105+ _ => unreachable ! ( ) ,
1106+ }
1107+ }
1108+
1109+ #[ test]
1110+ fn test_snowflake_create_iceberg_table_ctas ( ) {
1111+ match snowflake ( ) . verified_stmt (
1112+ "CREATE ICEBERG TABLE my_table EXTERNAL_VOLUME='volume' CATALOG='SNOWFLAKE' \
1113+ BASE_LOCATION='relative/path' AS SELECT 1",
1114+ ) {
1115+ Statement :: CreateTable ( CreateTable {
1116+ iceberg,
1117+ columns,
1118+ query,
1119+ base_location,
1120+ ..
1121+ } ) => {
1122+ assert ! ( iceberg) ;
1123+ assert ! ( columns. is_empty( ) ) ;
1124+ assert ! ( query. is_some( ) ) ;
1125+ assert_eq ! ( "relative/path" , base_location. unwrap( ) ) ;
1126+ }
1127+ _ => unreachable ! ( ) ,
1128+ }
1129+ }
1130+
1131+ #[ test]
1132+ fn test_snowflake_drop_iceberg_table ( ) {
1133+ match snowflake ( ) . one_statement_parses_to (
1134+ "DROP ICEBERG TABLE IF EXISTS my_table PURGE" ,
1135+ "DROP TABLE IF EXISTS my_table PURGE" ,
1136+ ) {
1137+ Statement :: Drop {
1138+ object_type,
1139+ if_exists,
1140+ names,
1141+ purge,
1142+ ..
1143+ } => {
1144+ assert_eq ! ( ObjectType :: Table , object_type) ;
1145+ assert ! ( if_exists) ;
1146+ assert ! ( purge) ;
1147+ assert_eq ! ( "my_table" , names[ 0 ] . to_string( ) ) ;
1148+ }
1149+ _ => unreachable ! ( ) ,
1150+ }
1151+
1152+ match snowflake ( ) . one_statement_parses_to ( "DROP ICEBERG TABLE my_table" , "DROP TABLE my_table" )
1153+ {
1154+ Statement :: Drop {
1155+ object_type,
1156+ if_exists,
1157+ purge,
1158+ ..
1159+ } => {
1160+ assert_eq ! ( ObjectType :: Table , object_type) ;
1161+ assert ! ( !if_exists) ;
1162+ assert ! ( !purge) ;
1163+ }
1164+ _ => unreachable ! ( ) ,
1165+ }
1166+ }
1167+
10541168#[ test]
10551169fn test_snowflake_create_table_trailing_options ( ) {
10561170 // Serialization to SQL assume that in `CREATE TABLE AS` the options come before the `AS (<query>)`
0 commit comments