Skip to content

fix(snowflake): match every recorded Snowflake receipt and re-record syntax coverage - #231

Merged
kvlonge merged 24 commits into
mainfrom
feat/syntax-fidelity-train
Nov 15, 2026
Merged

kvlonge merged 24 commits into
mainfrom
feat/syntax-fidelity-train

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Why

Snowflake receipts showed the parser disagreeing with Snowflake on 139 recorded statements, some kinds were still kept as opaque text, and many forms waited on receipts or reviews. This train fixes every contradiction, one commit per cause, and re-records coverage.

Changes

  • Probe-role receipts count when Snowflake parsed a statement or refused it with its syntax error; the case builder settles cases from them under any setup.
  • errno 90105 (no current database) is read as a post-parse semantic error.
  • UNDROP ... IDENTIFIER( ) is refused; trees no longer invent empty names.
  • Parser fixes, each with receipt tests: trailing commas Snowflake refuses; tags on CREATE OR ALTER / DEFINE SECRET; DROP ACCOUNT grace period and DROP MANAGED ACCOUNT; CREATE OPENFLOW CONNECTOR, DEPLOYMENT and RUNTIME as trees; string-only values (agent specification, scoring profile, replication schedule); OR REPLACE with IF NOT EXISTS on warehouses; online feature table without WAREHOUSE; one string as a share's SET ACCOUNTS.
  • Evidence pinned with two more recording batches; reviews recorded for re-read forms; baseline re-recorded.

Verification

  • syntax-coverage diff: 0 contradicted receipts, 0 unlisted, 0 disagreements added, 0 forms lost.
  • Verified forms 2,826 to 2,964 of 3,479: gross +170, drops 32, net +138. 20 drops are re-review rejections for tree, grammar or coverage defects; 12 wait on receipts the importer refused or that were never captured.
  • Known tree defect, counted as verified here: create_object writes "source":"" when there is no AS or CLONE clause. A follow-up PR fixes it and re-judges the affected forms.
  • 30 receipts with errno 603 (internal error) or 630 (timeout) stay unverified: neither establishes a parse phase.
  • Every fix has a test that fails without it. make check-ci passes on the final head.

…cases

Snowflake receipts now cover the cases whose SQL the list-item walk fix
corrected: the optional first item before a continuation, and the elided
group that drops its parenthesis. The marks follow the settled cases.
… forms

VALUES and three network and packages policy forms were read in full
again after their list-item cases were corrected and re-recorded. All
four are approved; DEFINE NETWORK POLICY stays unreviewed because its
tree does not record the DEFINE keyword. The baseline is re-recorded.
… run without privileges

A statement that must not take effect can be run, with no setup, by a
role that holds no privilege, so Snowflake parses it and then refuses it
at authorization or name resolution. The importer records such a row
with an empty setup and `no_effect = "probe_role"`, and refuses it
unless its phase is a refusal after parsing; one that ran is never a
receipt. The checker lets that receipt stand for its case whatever setup
the case names, since no setup changes whether Snowflake parses a
statement, and names any other no-effect receipt as a format problem.
…erated cases by their receipts

- Add an omission audit to the Snowflake obligations build: a catalogued form with a grammar and no
  obligations fails the build; retired aliases and fragments are listed.
- Derive obligations for number tokens, quoted fill classes, mixed-case quoted names, template
  alternatives, options-only alternatives, lower-case keyword values and empty list items.
- Let agreeing receipts decide a generated accept or reject case, and keep minimal boundary rows.
- Refresh the Snowflake catalogue and its sources.
…ep what was written

- Build structured create-object trees for the opaque CREATE and DEFINE kinds (agent, AI function,
  pipe with its COPY body, listing, model, notebook and others), with the DEFINE flag, optional WITH,
  TEMP versus TEMPORARY as written, task names as qualified names and SNOWFLAKE..<class> instances.
- Add named data types with precision and scale, stage references, GET/LIST/REMOVE and COPY trees,
  MERGE actions, RETURNS TABLE column quoting, and the class-method call `!method(args)` in a
  projection.
- Match receipts on accept or reject for ALTER, SHOW, sequence, external table, application
  package, notification integration and constraint forms.
- Split the stage models and ALTER TABLE parsing into their own modules.
…t run without privileges

No privilege or setup changes whether Snowflake parses a statement, so a
probe-role row now counts when Snowflake refused it after parsing or
with its syntax-error class: errno 1003 with "SQL compilation error:
syntax error ... unexpected". A parser or parse error with another
errno, an unsupported feature and a runtime error stay refused. The
checker admits the same two phases for a no-effect receipt and names any
other as a format problem.

A probe-role row also needs its run's audit to hold the end proof of the
probe role's grants, written only after the end walk of the roles the
probe inherits matched the start; a run whose end proof failed yields no
probe receipt.
…mitting empty names

Snowflake's parser rejects UNDROP <kind> IDENTIFIER ( <bare word> ) at the
top level with a syntax error, while the documented system-generated id,
IDENTIFIER( <number> ), is accepted for DATABASE, NOTEBOOK, SCHEMA, SNAPSHOT
and TABLE. Statements inside a Snowflake Scripting block are left alone,
since a variable may stand there.

Trees no longer carry an empty name standing in for an unwritten one:
- a table reference written through IDENTIFIER( ) omits its name;
- EXECUTE JOB SERVICE and EXECUTE INFERENCE JOB give a null object name;
- ALTER DYNAMIC TABLE ... SET TAG = <value> gives a null tag name;
- a bare ALTER RESOURCE MONITOR omits its empty action.

The UNDROP readings in the syntax limits now name both IDENTIFIER forms,
and the regenerated DDL obligations follow them.
…t-parse semantic error

Snowflake reports a session without a current database (errno 90105,
SQLSTATE 22000) only after the statement parsed, as the syntax limits
already record. The receipt classifier now gives it the semantic_error
phase, and a classifier case pins it.
The pinned evidence adds the receipts of the latest runner and
definition-file batches, including UNDROP by system-generated id and the
provisioned-throughput cases, all of which failed before execution. The
marks follow the regenerated cases.
…ttle, and disagreements the parser now resolves

The pinned receipts give a phase to 521 obligations recorded as not
submitted, and the rebuilt cases no longer cite a few entries whose
obligations were renumbered or withdrawn. 107 recorded disagreements now
agree with the parser.
…er any setup

A statement run by the probe role has no setup, so its receipt carries
the empty setup's hash. The syntax checker already admits such a receipt
for any setup when Snowflake parsed the statement or refused it with its
syntax error, but the case builder only settled a case from receipts
recorded under the case's own setup. Observed cases whose only receipts
came from the probe role therefore never settled and stayed awaiting
observation.

The builder now treats those probe-role receipts the way the checker
does: they settle a case under any setup, and they count against any
receipt recorded under the case's setup, so receipts that disagree still
settle nothing.
…from probe-role receipts

The pinned evidence settles 81 DDL and security cases from receipts the
probe role recorded, and their marks follow. UNDROP DATABASE, SNAPSHOT and
TABLE by a bare word inside IDENTIFIER( ), and the provisioned throughput
cases that put a bare word or a wrong kind where a string or number
belongs, now carry the outcome Snowflake recorded instead of waiting for
one.
UNSET lists of applications, databases, Streamlit apps and Openflow
objects, COPY = ( ... ) on tables and dynamic tables, a function's
PACKAGES, the columns of a described TABLE argument, MERGE INSERT columns
and values, a policy's arguments, and an interactive warehouse's TABLES
accepted a comma with nothing after it. Their receipts show Snowflake
refuses each one as a syntax error, while the same lists with an item
after every comma still parse. An interactive warehouse's TABLES list
also needs at least one table, as its receipt shows; an empty table COPY
list stays accepted.

The masking policy receipt this resolves leaves the disagreement list.
Snowflake refuses a TAG list, with or without WITH, on CREATE OR ALTER
SECRET and DEFINE SECRET as a syntax error for every secret type, while
the same statements without tags parse and CREATE SECRET keeps its tags.
The parser now refuses the tag list on those two forms.
…GED ACCOUNT

Snowflake parses DROP ACCOUNT <name> [ GRACE_PERIOD_IN_DAYS = <number> ]
and DROP MANAGED ACCOUNT <name>, refusing them only after parsing when the
role lacks the privilege, but the parser refused both kinds outright. Both
are now object drops; the grace period is kept as a property of the drop,
and a string, a missing number, a reserved word or a missing name stays
refused, as their receipts show.

DropObject gains an optional property list, left out of the tree when
empty, so every other dialect's drops serialize as before.
…E as trees

The three CREATE OPENFLOW kinds were kept as raw text, so the parser
accepted shapes Snowflake refuses: a connector without IN RUNTIME or
FROM, a bare word or string where a runtime, deployment or role name
belongs, and a trailing comma in a runtime's integrations. A structured
parser now reads each kind's head and documented properties, as all 153
recorded receipts for these statements show: the runtime or deployment
and the connector's definition or stage location are operands, a node or
deployment type is a keyword, and the integrations stay one list, which
may be empty.
Snowflake refuses a bare word, or no value, as an agent's live version
SPECIFICATION, as the profile of ADD SCORING PROFILE on a Cortex search
service, and as REPLICATION_SCHEDULE on CREATE FAILOVER GROUP and CREATE
REPLICATION GROUP. The parser now requires a string in each place.
Snowflake refuses CREATE OR REPLACE WAREHOUSE IF NOT EXISTS and CREATE
OR REPLACE INTERACTIVE WAREHOUSE IF NOT EXISTS as syntax errors, while
other kinds such as CONTACT still parse with both clauses. The parser now
refuses the combination for these two kinds only.
Snowflake parses CREATE ONLINE FEATURE TABLE without WAREHOUSE and only
rejects it after parsing. The parser no longer requires the property.
Snowflake parses ALTER SHARE ... SET ACCOUNTS = '<string>' with a single
string, while a string after an account name and a trailing comma are
still syntax errors. The parser now takes one string as the whole value.
… and trees changed, and re-record the baseline

The 94 forms held back only by a stale or missing review were read in
full again against their documentation page, obligations, cases, parse
trees and the newly pinned receipts. 35 are approved; the rest stay
unreviewed for tree, grammar or coverage findings the receipts did not
settle. The baseline is re-recorded against the current catalogue, so
obligations renumbered by the regenerated walk are counted by their new
ids.
… rows

The Snowflake catalogue build read a committed catalogue file as a plain
row, so the type checker could not iterate its form and definition
tables. The reader now returns the tables of rows that TOML gives.
@kvlonge
kvlonge enabled auto-merge November 15, 2026 00:38
@kvlonge
kvlonge added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit b6aa931 Nov 15, 2026
10 checks passed
@kvlonge
kvlonge deleted the feat/syntax-fidelity-train branch November 15, 2026 01:47
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