Skip to content

fix(syntax): parse Snowflake ALTER FUNCTION, PROCEDURE, SCHEMA, STAGE, SERVICE and 26 more kinds - #40

Merged
kvlonge merged 6 commits into
mainfrom
fix/snowflake-alter-alert-variable
Nov 4, 2026
Merged

kvlonge merged 6 commits into
mainfrom
fix/snowflake-alter-alert-variable

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Parses Snowflake ALTER of 31 more object kinds into the typed AlterObject statement that #37 added. Until now they went through the opaque Command fallback.

  • Routines: ALTER FUNCTION (UDF, external, service and data metric functions) and ALTER PROCEDURE. Both keep their argument types in a new AlterObject.arguments; a TABLE( ... ) argument is kept as a tuple.
  • Other kinds: ALERT, AGENT, ARTIFACT REPOSITORY, COMPUTE POOL, CONTACT, DATASET, DBT PROJECT, DCM PROJECT, EVENT ROUTING TABLE, EXTERNAL AGENT, EXTERNAL TABLE, EXTERNAL VOLUME, FILE FORMAT, GATEWAY, GIT REPOSITORY, LISTING, MATERIALIZED VIEW, MODEL, MODEL MONITOR, NOTEBOOK, ONLINE FEATURE TABLE, PIPE, RESTRICTED SESSION SCOPE / RSS, SCHEMA, SERVICE, STAGE, STREAM, TYPE and VARIABLE.
  • Layout: ALERT, ONLINE FEATURE TABLE, VARIABLE and FUNCTION live in parser/_helpers/ddl/snowflake_alter.rs. The other kinds are in a new snowflake_alter_resources.rs, which has one table of actions per kind and one shared SET/UNSET property parser. parse_alter is unchanged.
  • Behaviour taken from the receipts, not the pages:
    • Property names are open (SET v1 = 'm' parses), but a SET of TAG or CONTACT pairs sets nothing else.
    • A stage path ends at whitespace, so @"s1 Q" is not one path.
    • An incomplete kind such as ALTER COMPUTE, ALTER VOLUME or ALTER EVENT TABLE is a syntax error.
    • Only external tables add partitions (ALTER TABLE … ADD PARTITION is refused for Snowflake).
    • An agent SETs one literal property at a time.
    • A restricted session scope adds and removes its body without AS.
    • A dataset version comes from a query.
  • Tests: these extend tests/parser/test_snowflake_alter.rs.
  • No catalogue changes. main 4a8656b is merged in.

Receipt harness: every form in the batch agrees with its receipts. That's 168 forms and 2,766 scored cases (ALERT/OFT/VARIABLE 19/226, FUNCTION 28/448, the 21 kinds of the first resource batch 92/1,666, and the 8 kinds of the second 29/426), and #37's 50 forms and 699 cases still agree. The only mismatches are unscored observe rows: missing-name cases with errno 1003 and no position (reviewed as semantic), and MATERIALIZED VIEW SET CONTACT, which Snowflake refuses.

Coverage diff: family <f> --json for all ten families. It compares the gate-profile checker of main 4a8656b with this branch's (6ca671e), over catalogue f139639 plus evidence a299d23:

ddl                  forms +67 -0   obligations +4594 -0
security_admin       forms +0 -0   obligations +8 -0
forms completed: +67 -0; obligations satisfied: +4602 -0

D122a floor: +67 forms against a floor of 67 (2% of 3,348), so this PR gates on form count. By kind, the gain is FUNCTION 14, VARIABLE 5, ALERT 3, COMPUTE POOL 3, DBT PROJECT 3, MODEL 3, ONLINE FEATURE TABLE 3, PROCEDURE 3, SCHEMA 3, SERVICE 3, and 1–2 each for the other kinds. Most of the remaining forms in these kinds already agree with every receipt, but still wait on observe rows or on receipts that lane A is capturing (packets d40/d40b).

Merge order: after #38 and #39.

…RIABLE as a typed statement

These statements parse to AlterObject instead of the opaque Command
fallback:
- ALERT: RESUME/SUSPEND, SET, UNSET, FROM TEMPLATE ... SET, MODIFY
  CONDITION EXISTS ( <query> ) and MODIFY ACTION <statement>
- ONLINE FEATURE TABLE: SUSPEND/RESUME, REFRESH, RENAME TO, SET, and
  UNSET TAG <name> [ , ... ]
- VARIABLE: RENAME TO, SET/DROP DEFAULT, SET/UNSET COMMENT

ALTER ONLINE followed by anything other than FEATURE TABLE, and ALTER
FEATURE followed by anything other than POLICY, are now syntax errors in
Snowflake, as recorded.
… and service objects

ALTER FUNCTION (UDF, external, service and data metric functions) and
ALTER PROCEDURE keep their argument types, a TABLE( ... ) argument as a
tuple. ALTER AGENT, COMPUTE POOL, CONTACT, DBT PROJECT, DCM PROJECT,
EVENT ROUTING TABLE, EXTERNAL AGENT, EXTERNAL TABLE, FILE FORMAT,
GATEWAY, GIT REPOSITORY, LISTING, MODEL, MODEL MONITOR, NOTEBOOK,
SCHEMA, SERVICE and STAGE parse into AlterObject.

Following the recorded receipts: property names are open, a SET of TAG
or CONTACT pairs sets nothing else, a stage path ends at whitespace,
an incomplete kind such as ALTER COMPUTE is a syntax error, and only
external tables add partitions.
…ll parsers

Each group of actions (model versions, listing versions, service
sources, event routing rules and the remaining clauses) has its own
parser that takes and returns the action words, and kind and action
are matched together rather than compared.
…ts and materialized views

ALTER ARTIFACT REPOSITORY, DATASET, EXTERNAL VOLUME, MATERIALIZED VIEW,
PIPE, RESTRICTED SESSION SCOPE (and RSS), STREAM and TYPE parse into
AlterObject through the resource kinds.

Following the recorded receipts: a restricted session scope adds and
removes its body without AS (ADD AS is errno 1003), a dataset version
comes from a query, and ARTIFACT, MATERIALIZED, RESTRICTED SESSION and
VOLUME alone are no kind.
@kvlonge kvlonge changed the title fix(syntax): parse Snowflake ALTER ALERT, ONLINE FEATURE TABLE and VARIABLE fix(syntax): parse Snowflake ALTER FUNCTION, PROCEDURE, SCHEMA, STAGE, SERVICE and 25 more kinds Nov 4, 2026
@kvlonge kvlonge changed the title fix(syntax): parse Snowflake ALTER FUNCTION, PROCEDURE, SCHEMA, STAGE, SERVICE and 25 more kinds fix(syntax): parse Snowflake ALTER FUNCTION, PROCEDURE, SCHEMA, STAGE, SERVICE and 26 more kinds Nov 4, 2026

kvlonge commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merge gate (D94):

@kvlonge
kvlonge merged commit 00e831a into main Nov 4, 2026
kvlonge added a commit that referenced this pull request Nov 4, 2026
Conflicts were helper visibility (main's pub(super) kept) and the ddl module list (both modules kept).
kvlonge added a commit that referenced this pull request Nov 4, 2026
Basis: main 00e831a (PR #38, #39, #40), catalogue 5f35885,
evidence 469edde, parser tree 08415e1.

- 68 rebinds (ddl 1, expressions 6, functions 59, query 2): #39 put
  [[reading]] grammars into the definition hash; each fingerprint equals
  one an earlier full-read review approved.
- 149 newly approved forms (ddl 71, functions 56, scripting 14,
  expressions 5, query 2, transaction_session 1), read against their
  pinned pages and raw parser trees.
- Not approved: 37 forms with catalogue findings and 1 withhold
  (sf.ddl.drop-sequence: RESTRICT is dropped from the tree).

Checker at 00e831a: valid, 3476 forms; 1239 of 3348 verified.
@kvlonge
kvlonge deleted the fix/snowflake-alter-alert-variable 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