Skip to content

Snowflake create database #1939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

osipovartem
Copy link
Contributor

https://docs.snowflake.com/en/sql-reference/sql/create-database

Added support for

CREATE [ OR REPLACE ] [ TRANSIENT ] DATABASE [ IF NOT EXISTS ] <name>
   [ CLONE <source_schema>
       [ { AT | BEFORE } ( { TIMESTAMP => <timestamp> | OFFSET => <time_difference> | STATEMENT => <id> } ) ]
       [ IGNORE TABLES WITH INSUFFICIENT DATA RETENTION ]
       [ IGNORE HYBRID TABLES ] ]
   [ DATA_RETENTION_TIME_IN_DAYS = <integer> ]
   [ MAX_DATA_EXTENSION_TIME_IN_DAYS = <integer> ]
   [ EXTERNAL_VOLUME = <external_volume_name> ]
   [ CATALOG = <catalog_integration_name> ]
   [ REPLACE_INVALID_CHARACTERS = { TRUE | FALSE } ]
   [ DEFAULT_DDL_COLLATION = '<collation_specification>' ]
   [ STORAGE_SERIALIZATION_POLICY = { COMPATIBLE | OPTIMIZED } ]
   [ COMMENT = '<string_literal>' ]
   [ CATALOG_SYNC = '<snowflake_open_catalog_integration_name>' ]
   [ CATALOG_SYNC_NAMESPACE_MODE = { NEST | FLATTEN } ]
   [ CATALOG_SYNC_NAMESPACE_FLATTEN_DELIMITER = '<string_literal>' ]
   [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
   [ WITH CONTACT ( <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ] ) ]

Closes #1938

src/ast/mod.rs Outdated
Comment on lines 3860 to 3877
/// CREATE [ OR REPLACE ] [ TRANSIENT ] DATABASE [ IF NOT EXISTS ] <name>
/// [ CLONE <source_schema>
/// [ { AT | BEFORE } ( { TIMESTAMP => <timestamp> | OFFSET => <time_difference> | STATEMENT => <id> } ) ]
/// [ IGNORE TABLES WITH INSUFFICIENT DATA RETENTION ]
/// [ IGNORE HYBRID TABLES ] ]
/// [ DATA_RETENTION_TIME_IN_DAYS = <integer> ]
/// [ MAX_DATA_EXTENSION_TIME_IN_DAYS = <integer> ]
/// [ EXTERNAL_VOLUME = <external_volume_name> ]
/// [ CATALOG = <catalog_integration_name> ]
/// [ REPLACE_INVALID_CHARACTERS = { TRUE | FALSE } ]
/// [ DEFAULT_DDL_COLLATION = '<collation_specification>' ]
/// [ STORAGE_SERIALIZATION_POLICY = { COMPATIBLE | OPTIMIZED } ]
/// [ COMMENT = '<string_literal>' ]
/// [ CATALOG_SYNC = '<snowflake_open_catalog_integration_name>' ]
/// [ CATALOG_SYNC_NAMESPACE_MODE = { NEST | FLATTEN } ]
/// [ CATALOG_SYNC_NAMESPACE_FLATTEN_DELIMITER = '<string_literal>' ]
/// [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
/// [ WITH CONTACT ( <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ] ) ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re documentation, i think using a simple example or only mentioning that it represents the CREATE DATABASE statement would suffice, the actual spec we can delegate to the linked documentation for each dialect.

Comment on lines +9564 to +9568
impl ContactEntry {
pub fn new(purpose: String, contact: String) -> Self {
Self { purpose, contact }
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl ContactEntry {
pub fn new(purpose: String, contact: String) -> Self {
Self { purpose, contact }
}
}

I think we can remove this in order to keep the public API surface smaller

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we use instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has specific display format write!(f, "{} = {}", self.purpose, self.contact)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry to clarify I meant that we should remove the new function, not the struct itself. So that callers can manually do ContactEntry { purpose, "foo", contact: "bar" } instead of ContactEntry::new("foo", "bar")

@osipovartem osipovartem requested a review from iffyio July 15, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Snowflake CREATE DATABASE
2 participants