Skip to content

fix(syntax): read dynamic table, Postgres instance, event routing, grant and sequence statements as Snowflake does - #216

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

kvlonge merged 19 commits into
mainfrom
fix/syntax-pool-19

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Why

Recorded Snowflake verdicts disagreed with the parser on several object statements. Each fix follows a receipt.

Changes

  • Earlier batch: argument modes, a scoped temp table column's NULL, DATA MOVEMENT RULE option order, empty ALTER setting lists.
  • ALTER DYNAMIC TABLE: search optimization targets, column tag and masking policy UNSET, SET CONTACT, EXECUTE AS USER with secondary roles; clones copy grants, not tags.
  • A structured CREATE and ALTER POSTGRES INSTANCE parser replaces opaque text; DROP and DESC take INSTANCE alone.
  • Event routing rules need a string REGION_GROUP; SET RULE takes bare fields.
  • GRANT, REVOKE and SHOW GRANTS: single-word CREATE and IMPORT privileges, DATA EXCHANGE, more grantees; monitor, pool and package need their full kind.
  • ALTER SEQUENCE SET takes an integer INCREMENT, INCREMENT = is Snowflake only, and START takes the smallest 64-bit integer.
  • The importer reads these errnos as semantic, as Snowflake parsed first:
    • 1480 "Property 'DISTRIBUTION' must be specified"
    • 90201 "Missing name for argument 'NUMBER(38,0)'"
    • 90227 "Invalid use of IN/OUT parameters in non-SQL UDFs."
    • 92804 "The specified stage ST1 does not exist or the current role does not have access. Owner of the Streamlit must have at least READ on the specified stage."
    • 99133 "The specified stage ST1 does not exist or the current role does not have access. Owner must have at least READ on the specified stage."
    • 392030 "Streaming alert condition must not call a stored procedure or query from a VALUES clause"
  • Errno 921 is a syntax error when its message starts with "parse error": "parse error line 1 at position 44 unexpected end of SQL statement."
  • Two probe batches and the errno 921 receipt are pinned.

Verification

  • Coverage diff: 221 disagreements cleared, none added, no unlisted contradictions.
  • A review agreed with errnos 1480, 90201 and 921; its three small findings are fixed.
  • make check-ci passes on the final head.

…t questions, unrecorded

Each row is observed, so Snowflake's verdict decides it: DEFAULT after a
procedure argument mode, a mode on a function argument, an unnamed
procedure argument, LISTING without EXTERNAL or ORGANIZATION, stage paths
as listing and Streamlit locations, option order in CORTEX SEARCH
SERVICE, SERVICE, APPLICATION SERVICE and DATA MOVEMENT RULE, alert
conditions and actions beyond SELECT, a column constraint in a
procedure-scoped table, and empty integration lists.
… statement as semantic

Six errnos were refused as having no established phase. Each message
shows Snowflake parsed the statement and refused it on a rule about what
it says: a required listing property (1480), a missing stage for a
listing manifest or a Streamlit source (99133, 92804), an IN or OUT mode
on an argument of a UDF whose language takes none (90227), an argument
reported by its resolved type because it has no name (90201), and what a
streaming alert condition may call (392030). They are now reviewed as
semantic.
…nt questions

Snowflake refuses DEFAULT after an IN or OUT procedure argument mode, as
the parser does. It parses a bare LISTING, an unnamed procedure argument,
stage paths as listing and Streamlit locations, SERVICE with every option,
a tag list or a quoted specification, and alerts that call a procedure or
end in a block, which the parser accepts too.

Three receipts contradict the parser and are listed until it changes: a
mode on a function argument and a column constraint in a
procedure-scoped table, which Snowflake parses, and MAX_ROWS before TYPE
in a data movement rule, which it refuses. The bare LISTING rejection
that the guard used to hold is recorded, so it is no longer unobservable.
The recorded probes show where the parser differed from Snowflake:
- a mode after a function argument's name, as for a procedure argument,
  parses (Snowflake refuses it only for languages without modes);
- a procedure-scoped temporary table column may be NOT NULL or NULL;
- a data movement rule's TYPE comes before its MAX_ROWS body;
- an ALTER setting may take an empty list, as ALTER APPLICATION SERVICE,
  ALTER STREAMLIT and ALTER APPLICATION SET APP_SPEC do.
…es cleared

Remove the 14 receipt disagreements the parser now agrees with and
re-record the baseline for the obligations it gained.
…ds them

SUSPEND and RESUME SEARCH OPTIMIZATION take no ON targets, a column
action that unsets a tag names COLUMN, SET CONTACT takes no
parenthesized list, and SET EXECUTE AS USER accepts USE SECONDARY ROLES
ALL, NONE or a role list, which ends the SET list. The dynamic table
parser tests move to their own file.
Parse CREATE POSTGRES INSTANCE with its FORK source, AT or BEFORE time
travel, properties and tags, and ALTER POSTGRES INSTANCE with RENAME to
a name without TO, RESET ACCESS FOR, SUSPEND, RESUME, SET and UNSET,
instead of keeping them as opaque text. DROP and DESCRIBE accept
INSTANCE without POSTGRES, while CREATE and ALTER still need it.
…e does

Accept the single-word CREATE VOLUME, CREATE POLICY, CREATE REPLICATION,
IMPORT LISTING and IMPORT ORGANIZATION privileges, ON DATA EXCHANGE, a
database role granted to a database, a service role granted to an
application or database, SHOW GRANTS OF ROLE <instance>!<role> and SHOW
GRANTS TO a bare name. Refuse ON MONITOR, ON POOL and ON PACKAGE, which
only end a longer kind, and ON ALL or FUTURE without a plural.
ALTER SEQUENCE takes SET with INCREMENT, ORDER, NOORDER and COMMENT,
INCREMENT may take = without SET, and an ALTER SEQUENCE with no action
is refused. A signed integer is read with its sign, so START
-9223372036854775808 fits.
…nd event routing table questions

Each row is observed, so Snowflake's verdict decides it: dynamic table
clone options one at a time, SET CONTACT and combinations of SET
properties, a column policy UNSET without COLUMN, and each part of an
event routing rule. The TARGET_LAG and WAREHOUSE clone row duplicates a
documented case and is withdrawn.
…s the probe batch recorded

A dynamic table clone copies grants but not tags. In ALTER DYNAMIC TABLE
SET, FROZEN WHERE and EXECUTE AS USER are set on their own, and an ALTER
of a column without COLUMN unsets no masking policy. An event routing
rule's REGION_GROUP is a string; ALTER SET RULE takes the fields without
an assigned body and with optional commas, while a parenthesized rule
needs its commas.
Snowflake reports some refusals of its parser as errno 921 with a
message that starts with parse error, such as an unexpected end of the
statement. Such an error is now a syntax error; errno 921 with any other
message, or raised while a block runs, stays refused.
…an integer

Other dialects have no = after INCREMENT in ALTER SEQUENCE, so only
Snowflake takes it. ALTER SEQUENCE ... SET INCREMENT now refuses a
non-integer, as the form without SET already does.

The importer docs now say that errno 921 under the compilation prefix
is refused, and the importer tests cover that case and an upper-case
parse error message.
@kvlonge
kvlonge enabled auto-merge November 13, 2026 05:24
@kvlonge
kvlonge added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit e79e8d9 Nov 13, 2026
14 checks passed
@kvlonge
kvlonge deleted the fix/syntax-pool-19 branch November 13, 2026 06:41
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