Skip to content

feat(native): run semantic checks natively behind the preview engine - #1050

Merged
kvlonge merged 6 commits into
mainfrom
feat/native-semantic-checks
Oct 9, 2026
Merged

kvlonge merged 6 commits into
mainfrom
feat/native-semantic-checks

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Why

Semantic completion runs after model analysis. It recovers output types for failed models, adds B002 recovery notes, explains diagnostics and rejects unneeded sql_analysis false opt-outs. It still runs in Python and calls the Polyglot wheel to tokenize and parse failed models. This is the first part of moving the stage natively behind the native-preview engine.

Changes

  • New native module sqlbuild-analysis::semantic_checks ports:
    • type recovery: projection spans from the native tokenizer, poisoned outputs spread through compiled lineage, and the "downstream output uses were not type-checked" notes
    • B002 recovery and the "downstream uses ... were not checked" notes
    • explanations: closest-column help, schema evidence, alias qualifiers from the native parser, operand types and comparison help
    • opt-out rejection (P009) and the code-owned help texts
  • Python passes plain data from CompiledProject and applies the result. Shape publication and the binding-catalog revalidation stay Python inputs.
  • Anything the native code cannot reproduce exactly falls back to the Python stage. That covers non-ASCII text, unsupported dialects, unreadable SQL and native failures. Each fallback is recorded as a deferral.
  • Metadata checks (B300–B302, B102, wheel site Feat/bigquery adapter #7) still run in Python and are recorded as metadata_checks deferrals. A follow-up PR ports them.
  • The python and native engines are unchanged.

Verification

  • Rust unit tests; a parity property test against Python on generated failing projects in four dialects; failure-corpus cases; a DuckDB CLI E2E comparing all three engines
  • make compiler-differential with CI flags passes: 281 projects identical, analysis coverage 56/56, wheel sites feat: add shared type normalization #8 and Feat/databricks adapter #9 at 0 under preview
  • make compiler-differential-shipped, tests/e2e/scripts/compiler_differential, cargo test --workspace --all-features, clippy and fmt on 1.99.0, make check-ci, make test, hygiene scan

@kvlonge
kvlonge enabled auto-merge (squash) October 9, 2026 00:22
…checks

# Conflicts:
#	tests/e2e/scripts/compiler_differential/test_compiler_differential.py
#	tests/e2e/src/sqlbuild/cli/commands/main/compile/test_native_analysis_seams.py
…cks CLI test

Model analysis now records its own preview deferrals, so the semantic
checks test filters to its stage's sites.
@kvlonge
kvlonge merged commit 62cc5b8 into main Oct 9, 2026
37 checks passed
@kvlonge
kvlonge deleted the feat/native-semantic-checks branch October 9, 2026 04:42
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