Skip to content

fix(syntax): Snowflake ALTER, DROP, COMMENT ON and class method gaps - #51

Merged
kvlonge merged 4 commits into
mainfrom
fix/snowflake-alter-gaps-e
Nov 5, 2026
Merged

kvlonge merged 4 commits into
mainfrom
fix/snowflake-alter-gaps-e

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Snowflake parser gaps found by the syntax coverage checker: ALTER actions of tables, Iceberg tables, sequences, views, external tables and shares; DROP of security object kinds; COMMENT ON; and class instance method calls (CALL budget!GET_CONFIG()).

Changes

  • ALTER SEQUENCE RENAME TO and UNSET COMMENT; ALTER VIEW RENAME TO.
  • ALTER ICEBERG TABLE: CREATE [OR REPLACE] / REPLACE / ALTER / DROP VERSION_TAG with AS OF { VERSION | TIMESTAMP } n [ RETAIN n { DAYS | HOURS | MINUTES } ], REPLACE PARTITION BY ( e ) WITH ( e ), UPGRADE TO ICEBERG VERSION n, and OPTIMIZE ( REMOVE_POSITION_DELETES ). Plain ALTER TABLE refuses OPTIMIZE.
  • ALTER TABLE ADD STORAGE LIFECYCLE POLICY p ON ( cols ) and DROP STORAGE LIFECYCLE POLICY. RENAME needs TO, and RENAME TO, SWAP WITH and the table or view name refuse an unquoted reserved word.
  • ALTER EXTERNAL TABLE ADD/REMOVE FILES take a non-empty string list. ALTER SHARE UNSET COMMENT is typed, and its other actions keep the fallback. ALTER USER GROUP is refused (Snowflake has ALTER ORGANIZATION USER GROUP).
  • DROP of 35 security object kinds (policies, integrations, groups, ROLE, USER, SHARE, SECRET, …) is typed instead of an opaque command. DROP DATABASE keeps CASCADE/RESTRICT, and DROP FUNCTION refuses an empty or string TABLE ( ) argument.
  • COMMENT ON refuses reserved name parts and a non-string value in Snowflake.
  • CALL <instance>!<method>( … ) is a typed Call with the method as its member. It refuses a missing instance, method or parenthesis, and an unquoted reserved instance name. Other CALL forms are unchanged.

Not in this PR: B's #49 (DESC/SHOW, CREATE … FROM BACKUP/SHARE/REPLICA/ARCHIVE, CREATE TASK CLONE, TRUNCATE ERROR_TABLE, parse_object_name and parse_account_names). This branch only calls those functions. The ALTER TABLE column-action forms are also left out.

Coverage diff

Catalogue 1a57a55, evidence cfc73a0, checker built from each tree:

classes              forms +79 -0   obligations +1060 -0
ddl                  forms +20 -0   obligations +204 -0
security_admin       forms +33 -0   obligations +216 -0
forms completed: +132 -0; obligations satisfied: +1480 -0

Tests

crates/sqlquack-syntax/tests/parser/test_snowflake_alter_gaps.rs covers acceptance and refusal for each action, with receipt-backed cases where they exist, plus tree shape (kind, action, operands, call member).

Gate: make check-merge RECORDER=0 is running on head ea6266e (main 5cfdde2 merged in; main has no changes under crates/sqlquack-syntax* since 2f0c38a, so the coverage diff above holds). The result will be posted here.

- ALTER SEQUENCE RENAME TO and UNSET COMMENT; ALTER VIEW RENAME TO.
- ALTER ICEBERG TABLE version tags (CREATE [OR REPLACE], REPLACE, ALTER,
  DROP), REPLACE PARTITION BY ... WITH, UPGRADE TO ICEBERG VERSION and
  OPTIMIZE ( REMOVE_POSITION_DELETES ), which plain ALTER TABLE refuses.
- ALTER TABLE ADD STORAGE LIFECYCLE POLICY ... ON ( cols ) and DROP
  STORAGE LIFECYCLE POLICY; RENAME needs TO, and RENAME TO / SWAP WITH
  refuse an unquoted reserved word, as does the table or view name.
- ALTER EXTERNAL TABLE ADD/REMOVE FILES take a non-empty string list;
  ALTER SHARE UNSET COMMENT is typed; ALTER USER GROUP is refused.
- DROP of 35 security object kinds is typed instead of a command
  fallback; DROP DATABASE keeps CASCADE/RESTRICT; DROP FUNCTION refuses
  an empty or string TABLE ( ) argument.
- COMMENT ON refuses reserved name parts and a non-string value.
- CALL <instance>!<method>( ... ) is a typed call with the method as its
  member, and refuses a missing instance, method or parenthesis.
sqlglot's Snowflake identity fixture writes COMMENT ON ... IS N'...'; the
string check refused it, failing the polyglot exact-match run.
…aps-e

# Conflicts:
#	crates/sqlquack-syntax/src/parser/_helpers/ddl/mod.rs

kvlonge commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Gate (D94): make check-merge RECORDER=0 exit 0 on head 6a89ed2971068a09d79fa568a37f035093d89ede (main b323a31e merged in, so it fast-forwards). run_rust_tests: passed (23 binaries, including polyglot runs, which failed an earlier gate on COMMENT ON … IS N'…' and is fixed by e60fedc).

Coverage diff against main b323a31 (catalogue f61d213, evidence b22649e, checker built from each tree): forms completed +132 −0, obligations satisfied +1480 −0 (classes +79, ddl +20, security_admin +33).

Hygiene: author/committer 273747162+kvlonge@users.noreply.github.com, no trailers, no agent paths or private hosts in the diff.

@kvlonge
kvlonge merged commit 6a89ed2 into main Nov 5, 2026
kvlonge added a commit that referenced this pull request Nov 5, 2026
Basis: main 6a89ed2 (PR #51), catalogue f61d213, evidence b22649e,
parser tree c17d619.

- 120 forms approved (classes 73, security_admin 33, ddl 14): class
  instance method calls, DROP of security object kinds, ALTER table,
  Iceberg, external table and share actions.
- Not approved: 11 catalogue findings (budget shared-resource subquery
  instances, remove-tag/remove-resource-tag and set-email-notifications
  string operands, forecast series_colname, alter-external-table set,
  Iceberg upgrade version, replace partition expression, create
  version_tag interaction, comment.is object type) and 1 parser withhold
  (COMMENT ON quoting).

Checker at 6a89ed2: valid, 3476 forms, 0 problems; 1695 of 3348 verified.
@kvlonge
kvlonge deleted the fix/snowflake-alter-gaps-e branch November 9, 2026 21: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.

1 participant