Skip to content

fix: scenario, SQL test and dialect fixes for fixtures, checks and truth tests - #1147

Merged
kvlonge merged 12 commits into
mainfrom
fix/fixture-fill-and-snowflake-is-true
Oct 19, 2026
Merged

kvlonge merged 12 commits into
mainfrom
fix/fixture-fill-and-snowflake-is-true

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Why

Several SQL test, scenario and dialect bugs made valid projects fail on the warehouse or report misleading results: partial fixtures filled columns twice (CHI-630), Snowflake and SQL Server rejected IS [NOT] TRUE only at runtime (CHI-631), scenario expected output had to list every column and unrun checks showed zero counts (CHI-633, CHI-634), plus CHI-518, CHI-595 and CHI-476. A local test run also hit a stack overflow on deeply nested macro context values.

Changes

  • Fill each partial fixture column once, folding names per adapter.
  • Compile error for IS [NOT] TRUE/FALSE on Snowflake and SQL Server, with a rewrite suggestion.
  • Scenario expected output compares listed columns by name, like unit tests; expected_columns "all" restores the strict check. Missing columns are diagnosed before running; checks that didn't run report errors, not counts (--json: null counts, new comparison_status/query_status).
  • Scenario checks read the file's helper CTEs; redefining a helper is a compile error.
  • SQL Server freshness DDL, casefolded reference matching, one diagnostic for built-in audits on missing columns.
  • Grow the stack while keying nested macro values; make test fails when a worker crashes.

Verification

  • DuckDB E2E through sqb test/scenario test/compile for every fix; offline Snowflake and SQL Server rendering tests; Rust unit tests.
  • Focused suites and make test (all other tests passed before the crash fix); crash test passes on an 8 MB stack.
  • Independent review and one follow-up; non-blocking notes in CHI-641.
  • make check-ci and compiler differential pass.

Required fixture columns were deduplicated by their authored spelling, so a
column read as STATUS through a SELECT * import CTE and required again as the
declared status was completed twice. Key required columns by their casefolded
name, matching the metadata lookup, and complete each declared column at most
once.

Fixes CHI-630.
Both warehouses reject truth-value tests the SQL parser accepts, so models,
audits, SQL tests and hooks compiled cleanly and failed at execution. Report a
blocking B103 at the IS keyword of the authored resource with a null-safe
rewrite. DuckDB, MotherDuck, PostgreSQL, BigQuery and Databricks accept them.

Fixes CHI-631.
…heck

SQL Server has no CREATE TABLE IF NOT EXISTS. Guard the freshness table like the
other state tables and narrow its indexed key columns from NVARCHAR(MAX), which
SQL Server cannot index, to NVARCHAR(450).

Fixes CHI-518.
Relation and temporary-table names were lowercased rather than casefolded, so
names such as Straße and STRASSE did not match as they do in Python and the
runtime relation guard.

Fixes CHI-595.
A built-in audit attached to a column the model does not output was bound as
resource SQL and reported once per column reference at a made-up
audits/generic/<name>.sql path. Report one B002 per audit at its declaration in
MODEL() instead. Project audits that override a built-in keep their own file.

Fixes CHI-476.
…un comparisons

A scenario expected CTE listing fewer columns than its model failed in the
warehouse with a raw set-operation error, and the result still reported
0 mismatched with actual=0 expected=0. Reject an expected CTE that omits
model output columns or lists columns the model does not output with S512 at
planning time, and report a comparison that did not run with an ERROR status
and no counts; --json adds comparison_status and reports null counts.

Refs CHI-633.
A scenario __expected__ CTE had to list every column its model outputs, so
adding a column to a model broke every scenario covering it. Compare the listed
columns by name in both directions, as SQL unit tests do, and report missing
rows alongside mismatched ones. SCENARIO (expected_columns "all") restores the
requirement that every model column be listed, diagnosed with S512 before the
scenario runs.

Fixes CHI-633.
Scenario assertions and expected output ran without the file's helper CTEs,
so reading one failed in the warehouse with a missing-table error, and the
summary still reported 0 failing rows. Place the helpers a query reads, with
the helpers and fixtures they read, ahead of it in dependency order through
the SQL-test helper scope, build models an assertion reads through a helper,
and give fixtures only the helpers they read. An assertion that did not run
reports ERROR without a count; --json adds query_status and a null count.

Fixes CHI-634.
Keying a macro context value recurses once per nesting level up to the
900-level limit. In builds with large frames that recursion overflowed
an 8 MB stack and crashed the process instead of reporting the value as
unstorable. Each level now runs through stacker::maybe_grow, so the
depth limit is reached on any stack size.
A crashed xdist worker was replaced and the run then never finished.
With --max-worker-restart=0 the crash is reported as a failure and the
run ends.
Scenario checks now receive the file's helper CTEs, so an expected or
assertion CTE defining its own CTE with a helper's name failed in the
warehouse with a duplicate CTE name. Pass the checks into the helper
scope so the SQL-test shadowing check reports it at compile time.
@kvlonge
kvlonge enabled auto-merge (squash) October 18, 2026 23:10
CHI-634 gives each fixture only the helpers it reads, so the planner
fixture test no longer expects every fixture to carry every helper.
@kvlonge
kvlonge merged commit a411860 into main Oct 19, 2026
45 checks passed
@kvlonge
kvlonge deleted the fix/fixture-fill-and-snowflake-is-true branch October 19, 2026 00:23
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