Skip to content

feat(native): analyse models natively behind the preview engine - #1045

Merged
kvlonge merged 4 commits into
mainfrom
feat/native-model-analysis
Oct 9, 2026
Merged

kvlonge merged 4 commits into
mainfrom
feat/native-model-analysis

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

M4d, part 1 of 2. Model analysis runs natively under the native-preview engine, behind the M4b MODEL_ANALYSIS seam. It produces today's ModelSqlAnalysis per model, and every model whose result native cannot reproduce exactly is deferred to Python.

Changes

  • sqlbuild-analysis::assembly::analysis_session: an uncached session over the compile's ProjectCatalog. It covers the request, a session catalog copy, compact batches, topological waves, projection, the star/type pass, deferred binding validation and shape publication. It runs step by step and Python resumes it with answers to Defer.
  • Per-model deferrals, recorded under analysis_session: legacy analysis (refactor: expose row diff adapter hooks #2/feat: add query command #3) and input enrichment (site Docs/readme logo #1, ported in part 2). A cycle, a duplicate name or a session error hands the whole analysis back to Python.
  • Expression-source shapes are now inferred natively.
  • ProjectCatalog.inferred_schema now returns columns in their order instead of a hash map. This makes Python's published shapes deterministic in case-sensitive dialects.
  • The differential compares the binding catalog's schemas and analysis_shapes on the cold compile only; warm stages skip them because Python's analysis cache skips catalog preparation there.
  • Failure corpus cases, generated parity tests across four dialects, Rust unit tests and an updated DuckDB CLI seam test.

Verification

  • cargo test --workspace --all-features, clippy and fmt pass (1.99.0).
  • make compiler-differential with stage captures and all three coverage gates: 292 projects identical; analysis coverage 56/56. Native deferrals: 878 input enrichment, 12 legacy analysis.
  • make compiler-differential-shipped: 249 projects identical.
  • tests/e2e/scripts/compiler_differential passes (25 tests, incl. a wrong native catalog shape failing on cold compile).
  • make check-ci and make test pass (11818 tests).
  • Hygiene scan is clean.

Run the uncached model analysis as a native session: compact batches,
dataflow waves, shape publication, deferred binding validation and
expression-source shapes. Legacy analyses and input enrichment defer to
Python per model and are recorded.
…rals after the session

Keep the binding catalog's schemas and analysis shapes in captures and
ignore them only on warm stages, where Python's analysis cache skips
catalog preparation. Record per-model deferrals once the session
completes, and fall back to Python when provide or finish panics.
@kvlonge
kvlonge force-pushed the feat/native-model-analysis branch from d85da5f to 330c21b Compare October 9, 2026 00:37
@kvlonge
kvlonge enabled auto-merge (squash) October 9, 2026 00:38
@kvlonge
kvlonge merged commit 4d07a41 into main Oct 9, 2026
38 checks passed
@kvlonge
kvlonge deleted the feat/native-model-analysis branch October 9, 2026 02:04
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