Skip to content

feat(native): report SQL test and scenario errors natively - #1046

Merged
kvlonge merged 1 commit into
mainfrom
feat/native-sql-test-errors
Oct 8, 2026
Merged

kvlonge merged 1 commit into
mainfrom
feat/native-sql-test-errors

Conversation

@kvlonge

@kvlonge kvlonge commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Why

Native engines still re-ran Python to raise SQL test, scenario and scope-relationship errors: native scenario extraction and the relationship scans returned None on any error, and scenario source checks fell back on a reference error. Native should raise Python's exact error itself so the Python copy can go.

Changes

  • One native port of Python's top-level CTE scanner (sqlbuild-scopes) now returns names and bodies, Python's exact scanner errors (context, file, unclosed text, duplicate, AS, trailing statement, bare __expected__), or a deferral.
  • Scenario extraction uses it under the adapter's lexical rules and returns Python's classification errors (bare prefixes, macro mocks, missing fixtures or checks).
  • Scope relationship facts raise native test, scenario and macro-test scan errors in Python's first-error order.
  • Scenario source checks keep Python's order without a fallback.
  • Errors raised on these paths are marked bridge_independent.

Kept deferrals:

  • non-ASCII at code positions, Unicode case mapping, and comment prefixes Python's paren matcher ignores
  • the Polyglot CTE fallback when the scan fails and the text ends in SELECT 1
  • scenario check independence when Python would parse a check with Polyglot
  • omitted SELECT 1 detection (not an error path)

No mismatch cross-checks exist in this family. Parity is enforced by tests.

Verification

  • Generated parity: relationship scans on five dialects, scenarios, scope projects with broken tests and scenarios, and attachment projects, including first-error order.
  • E2E through the CLI on python, native and native-preview: identical reports, CompileInputError lifecycle type, no bridge re-runs. New cases are in the failure corpus.
  • cargo test --workspace --all-features, clippy and fmt on 1.99.0, make compiler-differential (CI flags), -shipped, tests/e2e/scripts/compiler_differential, make check-ci, make test, hygiene scan.

Scenario extraction, scope relationship scans and macro-test CTE scans
return Python's exact scanner and classification errors from one native
port of Python's top-level CTE scanner, under the adapter's lexical rules.
Scenario source checks no longer fall back to Python on a reference
error. Only Polyglot steps and non-ASCII classification still run in
Python.
@kvlonge
kvlonge merged commit 0e87c96 into main Oct 8, 2026
70 of 72 checks passed
@kvlonge
kvlonge deleted the feat/native-sql-test-errors branch October 8, 2026 23:47
kvlonge added a commit that referenced this pull request Oct 9, 2026
* feat(native): analyse models natively behind the preview engine

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.

* test(native): count only lineage deferrals in the fast lineage engine test

* test(native): use the native attachment entry field after #1043 and #1046

* fix(native): compare catalog shapes on cold compiles and record deferrals 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.
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