Snowflake: Support CLONE option in CREATE DATABASE/SCHEMA statements (#1958)

This commit is contained in:
Yoav Cohen 2025-07-21 14:41:20 +03:00 committed by GitHub
parent a73577c29f
commit 799c1f748d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 0 deletions

View file

@ -4296,6 +4296,7 @@ fn parse_create_schema() {
verified_stmt(r#"CREATE SCHEMA a.b.c WITH (key1 = 'value1', key2 = 'value2')"#);
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH (key1 = 'value1')"#);
verified_stmt(r#"CREATE SCHEMA IF NOT EXISTS a WITH ()"#);
verified_stmt(r#"CREATE SCHEMA a CLONE b"#);
}
#[test]
@ -7900,11 +7901,33 @@ fn parse_create_database() {
if_not_exists,
location,
managed_location,
clone,
} => {
assert_eq!("mydb", db_name.to_string());
assert!(!if_not_exists);
assert_eq!(None, location);
assert_eq!(None, managed_location);
assert_eq!(None, clone);
}
_ => unreachable!(),
}
let sql = "CREATE DATABASE mydb CLONE otherdb";
match verified_stmt(sql) {
Statement::CreateDatabase {
db_name,
if_not_exists,
location,
managed_location,
clone,
} => {
assert_eq!("mydb", db_name.to_string());
assert!(!if_not_exists);
assert_eq!(None, location);
assert_eq!(None, managed_location);
assert_eq!(
Some(ObjectName::from(vec![Ident::new("otherdb".to_string())])),
clone
);
}
_ => unreachable!(),
}
@ -7919,11 +7942,13 @@ fn parse_create_database_ine() {
if_not_exists,
location,
managed_location,
clone,
} => {
assert_eq!("mydb", db_name.to_string());
assert!(if_not_exists);
assert_eq!(None, location);
assert_eq!(None, managed_location);
assert_eq!(None, clone);
}
_ => unreachable!(),
}