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

Merged
merged 11 commits into from
Aug 1, 2025

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

@osipovartem osipovartem requested a review from iffyio July 15, 2025 11:31
@osipovartem
Copy link
Contributor Author

@iffyio please take a look

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

Thanks @osipovartem! Left a minor comment otherwise the changes look good to me

Comment on lines 9774 to 9781
/// Parse a boolean string
pub fn parse_boolean_string(&mut self) -> Result<bool, ParserError> {
match self.parse_one_of_keywords(&[Keyword::TRUE, Keyword::FALSE]) {
Some(Keyword::TRUE) => Ok(true),
Some(Keyword::FALSE) => Ok(false),
_ => self.expected("TRUE or FALSE", self.peek_token()),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

oh this looks like its only used once, can we inline it 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.

This will be used in the next PR
related to #1982

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, but I think we can inline it in this PR and if it ends up being used in the next PR we can break it out into a function. Also heads up for the function we would want to make it either private or pub(crate) visibility wise instead of pub

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced duplicated code by parse_boolean_string call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review again

@osipovartem osipovartem requested a review from iffyio July 30, 2025 21:17
Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @osipovartem!
cc @alamb

@iffyio iffyio merged commit ec0026d into apache:main Aug 1, 2025
10 checks passed
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