Snowflake: support trailing options in CREATE TABLE (#1931)

This commit is contained in:
Yoav Cohen 2025-07-14 10:16:20 +02:00 committed by GitHub
parent bc2c4e263d
commit 750a7aa054
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 80 additions and 20 deletions

View file

@ -995,6 +995,51 @@ fn test_snowflake_create_iceberg_table_without_location() {
);
}
#[test]
fn test_snowflake_create_table_trailing_options() {
// Serialization to SQL assume that in `CREATE TABLE AS` the options come before the `AS (<query>)`
// but Snowflake supports also the other way around
snowflake()
.verified_stmt("CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS AS (SELECT * FROM src)");
snowflake()
.parse_sql_statements(
"CREATE TEMPORARY TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS",
)
.unwrap();
// Same for `CREATE TABLE LIKE|CLONE`:
snowflake().verified_stmt("CREATE TEMPORARY TABLE dst LIKE src ON COMMIT PRESERVE ROWS");
snowflake()
.parse_sql_statements("CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS LIKE src")
.unwrap();
snowflake().verified_stmt("CREATE TEMPORARY TABLE dst CLONE src ON COMMIT PRESERVE ROWS");
snowflake()
.parse_sql_statements("CREATE TEMPORARY TABLE dst ON COMMIT PRESERVE ROWS CLONE src")
.unwrap();
}
#[test]
fn test_snowflake_create_table_valid_schema_info() {
// Validate there's exactly one source of information on the schema of the new table
assert_eq!(
snowflake()
.parse_sql_statements("CREATE TABLE dst")
.is_err(),
true
);
assert_eq!(
snowflake().parse_sql_statements("CREATE OR REPLACE TEMP TABLE dst LIKE src AS (SELECT * FROM CUSTOMERS) ON COMMIT PRESERVE ROWS").is_err(),
true
);
assert_eq!(
snowflake()
.parse_sql_statements("CREATE OR REPLACE TEMP TABLE dst CLONE customers LIKE customer2")
.is_err(),
true
);
}
#[test]
fn parse_sf_create_or_replace_view_with_comment_missing_equal() {
assert!(snowflake_and_generic()