Skip to content

fix(snowflake): finish the tree fidelity train with receipt-backed refusals and reviews - #244

Merged
kvlonge merged 33 commits into
mainfrom
fix/snowflake-tree-fidelity-final
Nov 16, 2026
Merged

kvlonge merged 33 commits into
mainfrom
fix/snowflake-tree-fidelity-final

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Why

Reviews rejected Snowflake trees that lost written keywords or kept options as text, and cases where an option only appeared in a statement Snowflake refused. The parser accepted statements receipts show Snowflake refusing, and six receipts recorded errno 1003 checks that run after parsing as syntax errors.

Changes

  • fix(snowflake): DATE_PART FROM, data metric TABLE() types, constraint modifiers, identity and sequence spellings, WITH before policies and tags, DEPLOY LAST / LATEST, IMPORTS aliases, SHOW SERVICES options, external table NOT NULL, AT / BEFORE after a FROM call, stage options, view RECURSIVE and the online feature table key keep their parts; event routing REGIONS are strings; SHOW OPENFLOW DATA PLANE INTEGRATIONS takes LIKE.
  • fix(snowflake): refuse UNSET = , a nameless SHOW PARAMETERS IN TABLE, MODIFY CONSTRAINT with columns, a bare out-of-line UNIQUE and a window name in a semantic view metric.
  • fix(tokenizer): // right after a stage path is part of it; after a space or punctuation it is a comment.
  • fix(syntax-receipts): four errno 1003 messages from checks after parsing are semantic errors; every other errno 1003 message stays a syntax error.
  • fix(syntax-cases): two-item continued lists, string REGION_GROUP, a case per option refused together, required ALTER USER names.
  • chore(syntax-coverage): evidence pinned with batch 37 and the reclassified receipts; reviews and baseline.

Still open: 152 forms stay unverified: 83 rejected at review (mostly options shown only in a refused statement, stage LOCATION as text, semantic view keywords, DESC vs DESCRIBE), 15 listed disagreements, the rest await receipts or are unobservable.

Verification

  • Parser and classifier fixes have tests that fail without them.
  • 3,199 of 3,351 Snowflake forms verified (was 3,087: 114 gained, 2 lost on DESC / DESCRIBE).
  • syntax-coverage diff exits 0 with nothing lost or contradicted.
  • make check-ci passes on the final head.

A call records on `from_separator` that FROM, not a comma, separates its
first two arguments, so DATE_PART ( DAY FROM d ) and DATE_PART ( DAY , d )
no longer give the same tree. Every other constructor sets it false. The
converter's DATE_PART rule reads both spellings the same way, and a test
runs both on DuckDB to show the translation is unchanged.
… functions

A TABLE ( <type> , ... ) argument in a function signature is now a
`table` data type with its column types, in DROP FUNCTION, DESC FUNCTION
and ALTER FUNCTION, instead of a type-name string, a raw parameter string
or a call named TABLE; DESCRIBE keeps its argument types as data types.
A data metric function's TABLE ( <table> ( <column> , ... ) ) argument
is a `referenced_table` with the table, its quoting and its columns.

The column types sit in their own struct so the data type's traversal
frame stays within the 512-level nesting guard on a 2 MB thread.
The reference parser consumed NOT while looking for NOT DEFERRABLE, so REFERENCES v1 NOT ENFORCED read as ENFORCED. It now takes NOT only together with DEFERRABLE.
…s and keep inline ones

ENABLE, DISABLE, ENABLE VALIDATE and ENABLE NOVALIDATE become enabled and
validated fields on constraint modifiers instead of raw words in properties.
An inline column constraint now carries the same typed modifiers as an
out-of-line one, so ENFORCED, NOT ENFORCED, DEFERRABLE, INITIALLY, RELY and
NORELY after an inline UNIQUE, PRIMARY KEY or REFERENCES are kept and typed.
A COMMENT after an inline constraint stays the column's comment.
…nd DYNAMIC tables

The checked table grammar kept each out-of-line constraint as a property
whose value mixed its columns with raw modifier words such as RELY and
COMMENT 'm'. The constraints are now typed table constraints in a new
constraints list on the created object, with the same modifier fields as
CREATE TABLE and ALTER TABLE ADD. A DEFINE's reference without FOREIGN KEY
records that the keywords were omitted.
…gs of columns

AUTOINCREMENT and IDENTITY, a parenthesized start and step and START ...
INCREMENT ..., and GENERATED ALWAYS AS and a bare AS each produced the same
column tree. Columns now record identity_spelling and identity_start_keyword,
and computed columns record generated_always, so each spelling is kept.
CREATE VIEW, CREATE MATERIALIZED VIEW and their columns read the optional
WITH before a policy or TAG clause but kept the same tree with or without
it. The clause's key now starts with WITH when it was written, as table
properties already do.
ALTER SEQUENCE INCREMENT [ BY ] [ = ] <n> now records BY and = in the same
spelling fields as CREATE SEQUENCE. In ALTER SEQUENCE SET, the property is
INCREMENT BY when BY was written, and a new eq flag on object properties
records the optional =.
…ex DDL

- ALTER DYNAMIC TABLE column actions keep a FORCE after SET MASKING or
  PROJECTION POLICY, which had no name or value and was dropped.
- DROP ROW ACCESS POLICY <p> , ADD ROW ACCESS POLICY ... records the
  addition as an ADD ROW ACCESS POLICY property on tables and dynamic tables.
- CREATE DYNAMIC ICEBERG TABLE, interactive and event tables keep a WITH
  before their policies and tags in the property kind.
- CREATE OR REPLACE INDEX records or_replace.
…apart

EXECUTE DCM PROJECT ... FROM DEPLOYMENT LAST or LATEST is now a keyword
value instead of an identifier, so it no longer reads like a deployment
named LAST; a quoted name stays an identifier. An IMPORTS alias keeps its
AS as a keyed part instead of a bare pair of strings.
SHOW SERVICES kept EXCLUDE JOBS and its OF TYPE list in the statement's
kind string. They are now an exclude_jobs flag and a service_types list,
and the kind stays SERVICES.
CREATE MODEL ... FROM '<stage>' and ALTER MODEL ... ADD VERSION ... FROM
'<stage>' kept the quoted stage as a string literal. They now give the same
stage reference, with each quoted name part, as COPY gives for the string.
…tage

A bare NOT NULL after an external table column's AS expression is the
column's inline constraint, not part of the expression; IS NOT NULL still
belongs to the expression. A quoted stage name in LOCATION keeps its quotes.
DYNAMIC_TABLE_REFRESH_BOUNDARY ( dt ) AT ( ... ) parsed the clause and
dropped it, since only a table reference has a place for it. A FROM call
followed by CHANGES or AT | BEFORE is now a table reference holding the
call, like IDENTIFIER( ); a call without a clause stays a call.
A stage reference's PATTERN was kept only when it was a string literal, so
PATTERN => name was dropped; it is now the expression as written, like
FILE_FORMAT, and the three copies of the option loop share one helper.
DIRECTORY ( @stage ) reads its argument as a stage reference rather than a
column, and a bare @ names no stage instead of a stage called @.
…on's REFRESH_MODE

RECURSIVE and the temporary scope words of CREATE VIEW were kept as
identifier properties, so LOCAL TEMP read as one name. RECURSIVE is now a
flag on the view and a scope other than TEMPORARY is its temporary
spelling, as for tables. A semantic view materialization's REFRESH_MODE
reads its documented keywords as keywords rather than object names.
Snowflake reads COPY FILES INTO @s1// FROM ... as a stage path, but the
tokenizer took // as a line comment and dropped the path and the FROM
source. A // written straight after an @ stage word now continues the
stage's path; after whitespace it is still a comment. The COPY grammar
check no longer needs its exception for the comment, and the FROM stage
tests move to their own file.
The key of CREATE ONLINE FEATURE TABLE was an unlabelled tuple of table
references. It is now a PRIMARY KEY part whose columns are identifiers
with their quoting; the FROM source stays the second operand.
For ( [ <arg> <type> ] [ , ... ] ), the case for "the list continued at
least once" left out the optional first item, so it rendered ( ) and
covered no continuation. When an optional item and a bare [ , ... ] fill
a parenthesized list, the continued case now writes the item and its
repeat, as ( v1 INT , v1 INT ). Other lists build the same cases as
before.
…mn tags exactly

Snowflake takes an event routing rule's REGION_GROUP only as a string, so
valid cases now fill it with 'g1' instead of a bare name.

The three hand-written limit rows for tags on one column carried a stray
extra tag, so the 19, 20 and 21 tag cases held 20, 21 and 22 tags.
…efused them all together

Hand rows kept several options of one form on the single all-options
statement Snowflake refused, so no option was ever shown valid on its own.
Removing those rows and their suppressions lets the refused statement
unpack into one case per option, as it already does for generated cases.
…refuses ALTER USER without it

Every recorded RENAME TO, SET or UNSET policy, and UNSET TAG statement
without a user name was a syntax error, so their valid operands now sit on
a named statement and the nameless one is a rejection.
… leaves out

Three CREATE PROCEDURE Syntax blocks carry a deprecation comment. It is
prose rather than grammar, so the readings now say the grammar leaves it
out on purpose. The grammar and its obligations are unchanged.
… list offset

The two case-builder tests now share one parametrised test that looks a
case up by its SQL, and the walk compares the item position without a bare
number.
…BLE, MODIFY CONSTRAINT columns and a bare UNIQUE

Recorded receipts show Snowflake refusing each of these as a syntax error:
UNSET <property> = <value>, SHOW PARAMETERS IN TABLE without a table,
MODIFY CONSTRAINT <name> ( <columns> ), and an out-of-line UNIQUE without a
parenthesised column list, which the parser read as a key on a column
named after the next word.
… a comment

A // straight after a stage continues its path, but the check walked back
to the last whitespace, so in LIST @s1;// note the // after the semicolon
was read as code. The walk now stops at the first character a stage path
cannot hold.
…awn errno 1003 receipts

The pinned evidence adds receipts for the new and changed cases, re-records
six cases whose only receipt came from the retired errno 1003 rule, and
withdraws those receipts and two orphans under that rule.
…OW DATA PLANE INTEGRATIONS LIKE

With the region group now a string, receipts reach the region list and show
Snowflake refusing a name, an empty list and a trailing comma there, so
REGIONS takes one or more strings. SHOW OPENFLOW DATA PLANE INTEGRATIONS
takes LIKE, which Snowflake accepted, and still no other option.
…ndow

A semantic view has no named windows, so OVER ( v1 ) inside CREATE or
DEFINE SEMANTIC VIEW is refused, matching the recorded errno 1003
receipts. Also applies rustfmt to the earlier refusal changes.
… semantic errors

Snowflake reports some checks that run after parsing succeeded with errno
1003: an unknown transaction, an unsupported version, an invalid
python_version and an invalid domain. Their messages are matched exactly
against the text after the compilation prefix line; every other errno 1003
message, including a positioned syntax error that quotes one of them,
stays a syntax error.

Also moves the semantic view window note into the doc comment.
… that now parse

Reading constraint modifiers after a foreign key's REFERENCES also reads
PostgreSQL's NOT VALID there, into the typed not_valid modifier.
@kvlonge
kvlonge enabled auto-merge November 16, 2026 04:55

kvlonge commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

PostgreSQL NOT VALID after a foreign key's REFERENCES: checked against PostgreSQL 18.7 (postgres:18 image). Each statement ran in its own transaction with its tables created, and was then rolled back.

Statement PostgreSQL 18.7 SQLQuack (this PR)
postgres_regress.json #1011 ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY (a) REFERENCES attmp2 MATCH FULL NOT VALID accepted parsed
#1189 ... FOREIGN KEY (a) REFERENCES atacc1 (a) NOT VALID accepted parsed
#1641 ... FOREIGN KEY (f1) REFERENCES alterlock (f1) NOT VALID accepted parsed
#9774 ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk NOT VALID accepted parsed
Control: CREATE TABLE c (a int, FOREIGN KEY (a) REFERENCES p NOT VALID) accepted parsed
Control: CREATE TABLE c (a int REFERENCES p NOT VALID) syntax error (42601) refused
Control: ALTER TABLE c ADD COLUMN a int REFERENCES p NOT VALID syntax error (42601) refused

The four re-recorded corpus verdicts (refused → parsed) are true accepts, and the column-level position PostgreSQL refuses is still refused.

@kvlonge
kvlonge added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 69edbca Nov 16, 2026
9 checks passed
@kvlonge
kvlonge deleted the fix/snowflake-tree-fidelity-final branch November 16, 2026 06:10
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