Snowflake: support trailing options in CREATE TABLE#1931
Merged
iffyio merged 4 commits intoapache:mainfrom Jul 14, 2025
Merged
Conversation
iffyio
reviewed
Jul 10, 2025
| /// Returns true if information on the structure of the table | ||
| /// to be created was provided to the builder. If not, the | ||
| /// statement is invalid. | ||
| pub fn has_schema_info(&self) -> bool { |
Contributor
There was a problem hiding this comment.
Suggested change
| pub fn has_schema_info(&self) -> bool { | |
| pub(crate) fn has_schema_info(&self) -> bool { |
Comment on lines
+390
to
+393
| !self.columns.is_empty() | ||
| || self.query.is_some() | ||
| || self.like.is_some() | ||
| || self.clone.is_some() |
Contributor
There was a problem hiding this comment.
could we add tests covering this behavior? e.g a test that fails when only a query, columns, like etc is provided in a create statement
Comment on lines
+1000
to
+1019
| snowflake() | ||
| .parse_sql_statements( | ||
| "CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS", | ||
| ) | ||
| .unwrap(); | ||
| snowflake() | ||
| .parse_sql_statements("CREATE TEMP TABLE tbl LIKE customers ON COMMIT PRESERVE ROWS;") | ||
| .unwrap(); | ||
| snowflake() | ||
| .parse_sql_statements("CREATE TEMP TABLE tbl CLONE customers ON COMMIT PRESERVE ROWS;") | ||
| .unwrap(); |
Contributor
There was a problem hiding this comment.
can we use verified_stmt here or similar roundtrip assertion?
Contributor
Author
There was a problem hiding this comment.
Improved the tests, note Snowflake supports specifying the options either before or after the "source" definition while the SQL output assumes one. Added tests for both options.
CREATE TABLE
dd8ad08 to
794cdcf
Compare
c21ea51 to
3aa41f3
Compare
iffyio
approved these changes
Jul 14, 2025
Contributor
iffyio
left a comment
There was a problem hiding this comment.
LGTM! Thanks @yoavcloud!
cc @alamb
ayman-sigma
pushed a commit
to sigmacomputing/sqlparser-rs
that referenced
this pull request
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code that parses
CREATE TABLEin the Snowflake dialect assumed that if theAS,LIKEorCLONEoptions are used, then no other options can be specified. That is not true, so that restriction is now removed.For example:
CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS