Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ pub fn parse_create_table(
builder.storage_serialization_policy =
Some(parse_storage_serialization_policy(parser)?);
}
Keyword::IF if parser.parse_keywords(&[Keyword::NOT, Keyword::EXISTS]) => {
builder = builder.if_not_exists(true);
}
_ => {
return parser.expected("end of statement", next_token);
}
Expand Down
12 changes: 12 additions & 0 deletions tests/sqlparser_snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@ fn test_snowflake_create_table_if_not_exists() {
}
_ => unreachable!(),
}

for sql in [
r#"CREATE TABLE IF NOT EXISTS "A"."B"."C" (v VARIANT)"#,
r#"CREATE TABLE "A"."B"."C" IF NOT EXISTS (v VARIANT)"#,
r#"CREATE TRANSIENT TABLE IF NOT EXISTS "A"."B"."C" (v VARIANT)"#,
r#"CREATE TRANSIENT TABLE "A"."B"."C" IF NOT EXISTS (v VARIANT)"#,
] {
// We don't use `verified_stmt` here because the parser won't produce a 1:1 result of the
// query. We will always put the `IF NOT EXIST` before the column name when displaying the
// query.
assert!(snowflake().parse_sql_statements(sql).is_ok());
}
}

#[test]
Expand Down