Skip to content

Accept Snowflake COPY GRANTS in CREATE TABLE - #2805

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
edeadington:fix/create-table-copy-grants
Oct 13, 2026
Merged

manticore-projects merged 1 commit into
JSQLParser:masterfrom
edeadington:fix/create-table-copy-grants

Conversation

@edeadington

@edeadington edeadington commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Snowflake's COPY GRANTS clause on CREATE TABLE no longer parses:

CREATE OR REPLACE TABLE t COPY GRANTS AS (SELECT a FROM src)
-- Encountered unexpected token: "COPY"

This used to work: there was never a dedicated rule for it, but COPY and GRANTS were plain identifiers, so the generic table option rule (CreateParameter()) accepted them. #2643 made COPY a reserved keyword for the new COPY statement, and the generic rule only accepts identifiers plus a fixed list of keywords, so COPY GRANTS stopped parsing as a side effect.

This PR adds COPY GRANTS as an explicit option in CreateTableOption(). It's only taken when COPY is directly followed by GRANTS, so COPY anywhere else, including a COPY statement, is parsed as before. The option is kept as a raw table option, so it prints back as COPY GRANTS.

The new test covers both Snowflake forms: after the table name in a CREATE TABLE ... AS query, and after a column list.

COPY became a reserved keyword with the COPY statement support in JSQLParser#2643,
so the generic CREATE TABLE option rule no longer accepts it and
CREATE TABLE ... COPY GRANTS fails to parse. Add COPY GRANTS as an
explicit table option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@edeadington
edeadington marked this pull request as ready for review October 13, 2026 11:12
@manticore-projects
manticore-projects merged commit a5ffe5c into JSQLParser:master Oct 13, 2026
10 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

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.

2 participants