Skip to content

fix: error a unit test when its tested output query fails - #1208

Merged
kvlonge merged 3 commits into
mainfrom
fix/unit-test-assert-errors
Oct 22, 2026
Merged

kvlonge merged 3 commits into
mainfrom
fix/unit-test-assert-errors

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Why

A unit test could report PASS while its tested model failed in the warehouse. SQLBuild stores a test's actual output once and compares against it. If storing failed for any reason, it silently fell back to the inline comparison. On a warehouse that prunes unread columns, that comparison of the expected columns alone can succeed while the full output fails, for example when a fixture value cannot be converted in a column the expected rows leave out.

Changes

  • When storing a test output fails, that step's output query now runs on its own, rendered fully inline so it does not read earlier steps' stored outputs. If it fails as well, the test errors with the warehouse's message and the run exits with code 1. A rendering failure still falls back without this check.
  • Only a failure to store a computable output, such as a session without temporary tables, still falls back to the inline comparison.
  • On DuckDB and MotherDuck, an internal engine error while storing an output compares inline as before. DuckDB 1.5.0 to 1.5.4 hit such an error on two identical window functions over a grouped constant fixture, while the inline comparison computes every column correctly.
  • The testing docs describe the rule.

Verification

  • E2E on DuckDB with a project adapter that prunes like such a warehouse: the test now ends as an error (text and --json, exit 1); a session that cannot store outputs still passes inline. Both error cases failed before the fix.
  • Multi-step chains (E2E and integration): when only a later step cannot be stored, a computable output passes inline and a failing one reports the warehouse's message, not a missing stored table.
  • Integration tests for both paths in SQL test execution; the existing unit test execution, cost-guard and test command suites pass.
  • Integration cases for an engine error while storing (passes, and still fails on a mismatch) and the real DuckDB repro; the varied compile fixture test passes.
  • make check-ci.

@kvlonge
kvlonge enabled auto-merge (squash) October 21, 2026 23:20
Storing a unit test's actual output once and comparing against it fell
back to the inline comparison on any storage error. On a warehouse that
prunes unread columns, the inline comparison of the expected columns can
pass when computing the full output fails, for example when a fixture value
cannot be converted in a column the expected rows leave out, so the test
reported PASS over a warehouse error. When storing fails, the output query
now runs on its own; if it fails too, the test errors with the warehouse's
message, and only a failure to store a computable output compares inline.
When a later chain step's output could not be stored, the probe ran that
step's query reading the earlier steps' stored outputs, which had just been
dropped, so it reported a missing table instead of comparing inline. The
probe now renders the failing step fully inline, runs only when storing
itself failed rather than rendering, and keeps the storage error in the
debug log when the step's query fails on its own.
DuckDB 1.5.0 to 1.5.4 raise an internal binder error for two identical
window functions over a GROUP BY of a constant input, which is the shape
of a unit test's fixture CTE. Storing the output and running it on its own
both hit it, so the output check reported the engine bug as the model's
error while the inline comparison computes every column correctly. An
internal engine error while storing an output now compares inline.
@kvlonge
kvlonge force-pushed the fix/unit-test-assert-errors branch from 18d62a5 to 46460a9 Compare October 22, 2026 00:16
@kvlonge
kvlonge merged commit e250b75 into main Oct 22, 2026
40 checks passed
@kvlonge
kvlonge deleted the fix/unit-test-assert-errors branch October 22, 2026 00:44
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