Skip to content

fix: keep stub-named CTEs from capturing references and the layered benchmark compiling - #880

Merged
kvlonge merged 2 commits into
mainfrom
fix/chi-414-412-benchmark-and-stubs
Sep 29, 2026
Merged

kvlonge merged 2 commits into
mainfrom
fix/chi-414-412-benchmark-and-stubs

Conversation

@kvlonge

@kvlonge kvlonge commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Why

The layered production benchmark generator no longer produced a compiling project (a schema used only from staging lived at project level, and seed-joined models used ambiguous id), and nothing caught it because its only consumer runs in a disabled performance job. Separately, compact analysis without a binding schema could let an authored CTE named like an internal relation stub capture relation references.

Changes

  • Layered generator: schema placed in models/staging/_sqlbuild/_schemas/, seed-joined models qualify their columns; the disabled layered guard's hook expectation matches current generation (0).
  • New E2E test compiles a 350-model layered project with zero diagnostics.
  • Shared relation_stubs_collide guard (casefolded prefix in SQL or relation names) now also protects compact non-binding analysis, which falls back to real names.
  • Unit test for lowercase and uppercase stub-named CTEs; E2E build test for correct types and B002.

Verification

  • Unit regression fails before the fix; layered test fails on the old generator; dense fingerprint unchanged.
  • make test, make check-ci, hygiene scan; one independent review (no findings).

The layered generator placed its contract schema in project-wide schemas/
although only the first staging model uses it (S024), and its seed-joined
models referenced id unqualified (B003). Place the schema beside its only
consumer, qualify input columns, and refresh the stale hook count in the
disabled layered performance guard. Add a small non-performance E2E compile
of the layered project so the generator cannot silently break again.

Refs: CHI-414
Compact analysis without a binding schema replaced relation references
with __sqlbuild_project_input_N stubs without checking the authored SQL,
so a CTE with that name (any case) captured the reference and analysis
inferred the CTE's shape instead of the input's. Share the binding-mode
sharing guard and fall back to real relation names when the stub prefix
appears in the SQL or a relation name.

Refs: CHI-412
@kvlonge
kvlonge enabled auto-merge (squash) September 29, 2026 07:25
@kvlonge
kvlonge merged commit 5adf6a4 into main Sep 29, 2026
29 checks passed
@kvlonge
kvlonge deleted the fix/chi-414-412-benchmark-and-stubs branch September 29, 2026 07: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