Skip to content

fix: Snowflake SQL tests read expected columns through __ref() and table function calls - #1736

Merged
kvlonge merged 1 commit into
mainfrom
fix/snowflake-expected-ref
Nov 30, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/snowflake-expected-ref

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Why

On Snowflake, an __expected__<model> CTE that reads another relation through __ref() (in a join, a WHERE subquery, or a __table_fn call) failed compile with an internal S000 error. The expected body was parsed as authored, and the Snowflake parser can't read a bare __ref("x") table call.

Changes

  • Expected columns are read from the body with each relation marker as a plain name, and on Snowflake each __table_fn call wrapped in TABLE( ), the same way rule trees are parsed. Error positions map back to the authored body.
  • A body whose columns can't be read is a user error, P028, instead of S000: it names the test and CTE, and either the line, column and parser reason, or why the columns aren't named (a repeated name, an unnamed expression, SELECT *, no columns).
  • Snowflake parse errors are placed at the right character when multibyte text comes before them. This also corrects the column P026 reports.
  • Snowflake scenarios whose expected CTE reads __ref() now compare columns by name, as documented, instead of by position.
  • Docs: two rows in the testing page's CTE syntax table; skill regenerated.
  • DuckShop: a unit test whose expected CTE joins and filters through __ref(), with expectations derived by hand.

Verification

  • New e2e (Snowflake, --run-on local): join, WHERE subquery and mocked-model join pass; a wrong value fails with exit 1; an unparseable body fails with P028. All five fail with S000 on main.
  • Rust cases for each shape, multibyte text, a table function argument error, and a SELECT with no columns.
  • New failure-corpus golden for P028; all other goldens unchanged.
  • DuckShop sqb compile --no-cache, same machine, 3 alternating runs, medians without the new case: base 2.02 s wall / 5.73 s CPU, head 2.03 s / 5.80 s; phase timings and diagnostics unchanged. With it, base stops with S000 and head compiles clean.
  • Targeted tests and make check-ci pass.

…ble function calls

On Snowflake, an expected CTE that read another relation through
__ref() failed compile with S000: its body was parsed as authored, and
the Snowflake parser can't read a bare __ref("x") table call.

Expected columns are now read with each relation marker as a plain
name, and on Snowflake each __table_fn call in TABLE( ), as rule trees
are. Error positions map back to the authored body. A body whose
columns can't be read is P028, naming the test, the CTE and either the
parser's reason and position or why its columns aren't named.

Snowflake parse errors now carry byte offsets, as ParserGap documents,
so a parse error after multibyte text is placed at the right column;
this also corrects P026.
@kvlonge
kvlonge enabled auto-merge November 30, 2026 16:27
@kvlonge
kvlonge added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit a9a442f Nov 30, 2026
38 checks passed
@kvlonge
kvlonge deleted the fix/snowflake-expected-ref branch November 30, 2026 17:40
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