File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -386,7 +386,7 @@ impl CreateTableBuilder {
386
386
/// Returns true if information on the structure of the table
387
387
/// to be created was provided to the builder. If not, the
388
388
/// statement is invalid.
389
- pub fn has_schema_info ( & self ) -> bool {
389
+ pub ( crate ) fn has_schema_info ( & self ) -> bool {
390
390
!self . columns . is_empty ( )
391
391
|| self . query . is_some ( )
392
392
|| self . like . is_some ( )
Original file line number Diff line number Diff line change @@ -997,19 +997,40 @@ fn test_snowflake_create_iceberg_table_without_location() {
997
997
998
998
#[ test]
999
999
fn test_snowflake_create_table_trailing_options ( ) {
1000
+ // Serialization to SQL assume that in `CREATE TABLE AS` the options come before the `AS (<query>)`
1001
+ // but Snowflake supports also the other way around
1002
+ snowflake ( )
1003
+ . verified_stmt ( "CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS AS (SELECT * FROM src)" ) ;
1000
1004
snowflake ( )
1001
1005
. parse_sql_statements (
1002
- "CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS" ,
1006
+ "CREATE TEMPORARY TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS" ,
1003
1007
)
1004
1008
. unwrap ( ) ;
1009
+
1010
+ // Same for `CREATE TABLE LIKE|CLONE`:
1011
+ snowflake ( ) . verified_stmt ( "CREATE TEMPORARY TABLE dst LIKE src ON COMMIT PRESERVE ROWS" ) ;
1005
1012
snowflake ( )
1006
- . parse_sql_statements ( "CREATE TEMP TABLE tbl LIKE customers ON COMMIT PRESERVE ROWS; " )
1013
+ . parse_sql_statements ( "CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS LIKE src " )
1007
1014
. unwrap ( ) ;
1015
+
1016
+ snowflake ( ) . verified_stmt ( "CREATE TEMPORARY TABLE dst CLONE src ON COMMIT PRESERVE ROWS" ) ;
1008
1017
snowflake ( )
1009
- . parse_sql_statements ( "CREATE TEMP TABLE tbl CLONE customers ON COMMIT PRESERVE ROWS; " )
1018
+ . parse_sql_statements ( "CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS CLONE src " )
1010
1019
. unwrap ( ) ;
1011
1020
}
1012
1021
1022
+ #[ test]
1023
+ fn test_snowflake_create_table_has_schema_info ( ) {
1024
+ // The parser validates there's information on the schema of the new
1025
+ // table, such as a list of columns or a source table\query to copy it from.
1026
+ assert_eq ! (
1027
+ snowflake( )
1028
+ . parse_sql_statements( "CREATE TABLE dst" )
1029
+ . is_err( ) ,
1030
+ true
1031
+ ) ;
1032
+ }
1033
+
1013
1034
#[ test]
1014
1035
fn parse_sf_create_or_replace_view_with_comment_missing_equal ( ) {
1015
1036
assert ! ( snowflake_and_generic( )
You can’t perform that action at this time.
0 commit comments