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

@ -4347,8 +4347,9 @@ fn parse_create_table_as() {
// BigQuery allows specifying table schema in CTAS
// ANSI SQL and PostgreSQL let you only specify the list of columns
// (without data types) in a CTAS, but we have yet to support that.
let dialects = all_dialects_where(|d| d.supports_create_table_multi_schema_info_sources());
let sql = "CREATE TABLE t (a INT, b INT) AS SELECT 1 AS b, 2 AS a";
match verified_stmt(sql) {
match dialects.verified_stmt(sql) {
Statement::CreateTable(CreateTable { columns, query, .. }) => {
assert_eq!(columns.len(), 2);
assert_eq!(columns[0].to_string(), "a INT".to_string());
@ -4453,20 +4454,6 @@ fn parse_create_or_replace_table() {
}
_ => unreachable!(),
}
let sql = "CREATE TABLE t (a INT, b INT) AS SELECT 1 AS b, 2 AS a";
match verified_stmt(sql) {
Statement::CreateTable(CreateTable { columns, query, .. }) => {
assert_eq!(columns.len(), 2);
assert_eq!(columns[0].to_string(), "a INT".to_string());
assert_eq!(columns[1].to_string(), "b INT".to_string());
assert_eq!(
query,
Some(Box::new(verified_query("SELECT 1 AS b, 2 AS a")))
);
}
_ => unreachable!(),
}
}
#[test]