Skip to content

perf: run semantic validation on the shared scope tree - #31

Merged
kvlonge merged 9 commits into
mainfrom
perf/fused-validation
Sep 27, 2026
Merged

kvlonge merged 9 commits into
mainfrom
perf/fused-validation

Conversation

@kvlonge

@kvlonge kvlonge commented Sep 27, 2026

Copy link
Copy Markdown

Why

Semantic validation rebuilt work that analysis and its own reference pass had already done: a scope tree per SELECT for the semantic checks, SELECT copies to strip WITH clauses, repeated whole-tree walks, and a deep comparison of whole derived-table queries per column lookup. On a 3,000-model project this roughly tripled native analysis time.

Changes

  • Per-SELECT semantic checks run on the reference-validation scope tree instead of building a scope per SELECT. A SELECT inside a CTE body now sees the CTEs defined before it, which removes a false E201 when a CTE shadows a table of the same name (covered by a DuckDB-checked test). DML and other statements keep the standalone path.
  • One traversal collects set-operation ORDER BY findings, SELECT counts, projection stars and lambdas; lambda binding is skipped when there are none.
  • Validation scope views take ownership of their queries instead of copying them; dotted-column normalisation is skipped when every qualifier names a source.
  • Derived-table child-scope lookups are cached in lineage and nullability analysis.
  • Version 0.13.8.

Verification

  • cargo test --lib -p polyglot-sql: 1343 passed; make test-rust-feature-gates and make check-consistency pass; query-analysis, regression and type-truth suites pass (the existing analyze_query_set_operation_name_alignment_and_cast_consensus_454 failure on main is unchanged).
  • Downstream, diagnostics are identical on a semantic corpus and generated 3,000-model projects, with native analysis roughly 40% faster.

@kvlonge
kvlonge merged commit 25ad011 into main Sep 27, 2026
24 checks passed
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