Skip to content

fix(syntax): read more Snowflake object statements as Snowflake does - #214

Merged
kvlonge merged 11 commits into
mainfrom
fix/syntax-pool-18
Nov 13, 2026
Merged

kvlonge merged 11 commits into
mainfrom
fix/syntax-pool-18

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Why

Recorded Snowflake verdicts show the parser accepting any text after several object kinds, because it kept those statements as opaque text, and refusing documented forms of others. An opaque statement also can't be linted, and DEFINE refuses it.

Changes

  • Parse these CREATE forms against their grammars instead of keeping them as text: BACKUP SET and SNAPSHOT SET, APPLICATION, CORTEX SEARCH SERVICE, SERVICE, APPLICATION SERVICE, EXTERNAL and ORGANIZATION LISTING, STREAMLIT, ALERT, and DATA MOVEMENT RULE. DEFINE accepts the same forms.
  • Accept ALTER DATA MOVEMENT RULE, including SET MAX_ROWS.
  • For procedures, read IN, INPUT, OUT and OUTPUT after an argument's name as its mode, accept a bare word for RUNTIME_VERSION and PACKAGES and a string for ARTIFACT_REPOSITORY, and parse CREATE PROCEDURE SCOPED TEMP TABLE.
  • DEFINE DATABASE and DEFINE SCHEMA accept properties, which are checked word by word before they are kept as text.
  • A bare CREATE LISTING keeps its existing path, since no recorded case shows how Snowflake reads it.

Verification

  • Against the pinned recorded cases for the changed forms, this clears 365 false accepts and 131 false rejects. Every recorded function verdict is unchanged.
  • Four recorded procedure refusals combine an argument mode with DEFAULT. The parser now refuses DEFAULT after a mode, which keeps them refused. The documented grammar allows it, so this is a guess that the next recording batch tests directly.
  • Remaining disagreements in these forms: CREATE statements that name no kind, a bare CREATE LISTING ... FROM, and ALTER STREAMLIT SET with an empty list.
  • New parser tests for each form, with recorded refusals as controls. cargo test -p sqlquack-syntax-snowflake, clippy and fensu pass.
  • 396 receipt disagreements are removed and none added; the baseline is re-recorded. make check-ci passes on the final head.

…Snowflake does

These three kinds fell through to the opaque CREATE text, which accepted
every malformed variant Snowflake refuses: a set without FOR or with an
unknown target, the wrong policy kind, a property list after the
target, an application without FROM, a string package name, USING
without VERSION, RELEASE CHANNEL or a path, and PATCH without its
number. They now parse as structured objects that keep their kind,
source, target and properties. CREATE SET, BACKUP or SNAPSHOT followed
by a name and FOR is refused as an incomplete set kind.
…ng decisions

Read USING RELEASE CHANNEL against VERSION as a matched flag and build
each CreateObject in place, as the repository's layout rules require.
Parse the service ON one search column or with TEXT and VECTOR INDEXES,
then an optional PRIMARY KEY and ATTRIBUTES, its properties and AS with a
query, instead of accepting any text after the kind. All 133 recorded
cases for the two forms now agree with Snowflake, which clears 35 false
accepts.
… does

Parse a service IN COMPUTE POOL FROM a staged or inline specification or
template, with USING arguments for a template, and an application service
FROM ARTIFACT REPOSITORY with its PACKAGE and VERSION, then their options
with a tag list last. Of 210 recorded cases, 209 now agree with Snowflake,
which clears 53 false accepts; the other is a CREATE that names no kind.
…ke does

Parse the listing's optional SHARE or APPLICATION PACKAGE, then AS its
manifest text or FROM its stage location, then its options, instead of
accepting any text after the kind. Of 107 recorded cases, 104 now agree
with Snowflake, which clears 44 false accepts; a bare CREATE LISTING keeps
its existing path, since no recorded case shows how Snowflake reads it AS
a manifest.
… tables

Read IN, INPUT, OUT and OUTPUT after a procedure argument's name as its
mode, accept a bare word for RUNTIME_VERSION and PACKAGES and a string for
ARTIFACT_REPOSITORY, and parse CREATE PROCEDURE SCOPED TEMP TABLE with its
columns. This clears 35 recorded false rejects and leaves every recorded
function verdict unchanged. Three recorded refusals that combine a mode
with DEFAULT and several other options now parse; which part Snowflake
refuses is not yet recorded.
Parse a Streamlit app's name, optional FROM source location and its
properties instead of keeping the statement as opaque text, which DEFINE
refuses. Of 332 recorded cases, 330 now agree with Snowflake: 22 false
rejects and 1 false accept are cleared, and ALTER STREAMLIT SET with an
empty list remains refused.
A database's or schema's properties are checked word by word and then
kept as source text, which DEFINE took for an opaque definition and
refused. DEFINE now looks past those checked properties and still refuses
any other text node. This clears 37 recorded false rejects.
Parse an alert's properties, tag list and STARTED or SUSPENDED state, then
IF ( EXISTS ( <condition> ) ) THEN <action>, or FROM TEMPLATE with its
properties, instead of keeping the statement as opaque text. A clone keeps
its existing path. Of 400 recorded cases, 397 now agree with Snowflake,
which clears 15 false rejects and 14 false accepts; the rest are CREATEs
that name no kind.
Parse a data movement rule's TYPE, its MAX_ROWS AS ( ) RETURNS <type> ->
<expression> body and a string COMMENT, and accept ALTER DATA MOVEMENT
RULE with RENAME TO, SET and UNSET. All 174 recorded data movement cases
now agree with Snowflake, which clears 22 false rejects and 2 false
accepts.
…cleared

Remove the 396 receipt disagreements these parsers now agree with, and
re-record the baseline for the obligations they gained.
@kvlonge
kvlonge enabled auto-merge November 13, 2026 01:46
@kvlonge
kvlonge added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 5b888e6 Nov 13, 2026
14 checks passed
@kvlonge
kvlonge deleted the fix/syntax-pool-18 branch November 13, 2026 02:50
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