Snowflake: Accept COPY GRANTS after CREATE VIEW column list#2327
Open
97nitt wants to merge 2 commits intoapache:mainfrom
Open
Snowflake: Accept COPY GRANTS after CREATE VIEW column list#232797nitt wants to merge 2 commits intoapache:mainfrom
97nitt wants to merge 2 commits intoapache:mainfrom
Conversation
Snowflake documents `COPY GRANTS` as appearing after the column list on `CREATE VIEW`. The parser already accepted it before the column list; also accept it after, normalizing Display to the pre-columns form.
iffyio
reviewed
Apr 29, 2026
Comment on lines
+4769
to
+4773
| // Snowflake's documented placement for `COPY GRANTS` on `CREATE VIEW` is | ||
| // *after* the column list. Display normalizes to the pre-columns form | ||
| // already supported, so use `one_statement_parses_to` to assert the | ||
| // post-columns input is accepted and the AST flag is set. | ||
| // <https://docs.snowflake.com/en/sql-reference/sql/create-view#syntax> |
Contributor
There was a problem hiding this comment.
Suggested change
| // Snowflake's documented placement for `COPY GRANTS` on `CREATE VIEW` is | |
| // *after* the column list. Display normalizes to the pre-columns form | |
| // already supported, so use `one_statement_parses_to` to assert the | |
| // post-columns input is accepted and the AST flag is set. | |
| // <https://docs.snowflake.com/en/sql-reference/sql/create-view#syntax> |
| ]; | ||
| for (sql, parsed) in cases { | ||
| match snowflake().one_statement_parses_to(sql, parsed) { | ||
| Statement::CreateView(CreateView { |
Contributor
There was a problem hiding this comment.
we can drop the ast assertions in the tests
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.
Summary
Snowflake's
CREATE VIEWsyntax documentsCOPY GRANTSas appearingafter the column list:
The parser already accepted
COPY GRANTSbefore the column list, butrejected the documented post-columns position. This PR accepts either
position (but not both).
Changes
parse_create_view: after consuming the column list, attempt a secondCOPY GRANTSmatch if one wasn't already seen.Displaycontinues to emit the pre-columns form, so the post-columns inputround-trips to the existing canonical shape.
VIEW,SECURE VIEW, andMATERIALIZED VIEWwithpost-columns
COPY GRANTS, and a baseline asserting the flag is notspuriously set when
COPY GRANTSis absent.Test plan
cargo testcargo fmt --checkcargo clippy --all-targets --all-features -- -D warnings