v1.10.0 — Column lineage foundations - #11
Merged
Merged
Conversation
…ics) Single-statement column scopes and bindings for qualified refs, aliases, projections, CTEs, derived tables, and catalogue-backed wildcard expansion; expression-level provenance; explicit column_ambiguous/column_opaque region diagnostics. src/columns.ts + tests/columns.ts (18 fixtures), wired into analyse(), metrics corpus, docs, and example; dist rebuilt in sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: v1.10.0 — Column lineage foundations
Summary
Implements the v1.10.0 — Column lineage foundations milestone from
ROADMAP.mdin full and nothing from v1.11.0 onwards: column scopes andbindings for qualified references, aliases, projections, CTEs, derived
tables, and catalogue-backed wildcard expansion; expression-level
provenance within one query statement; and explicit ambiguous and opaque
column references. The golden suite grows from 208 to 209; fuzz (400) and UI
(22) stay green; 18 column fixtures assert exact input→output mappings and
spans, that ambiguity never invents a column binding, and that unsupported
expressions become opaque with region-scoped diagnostics. Multi-statement
temporary-table column flow, inter-object column flow, the column export
contract (all v1.11.0), and RDL (v1.12.0) remain deferred.
What's included
Column-lineage module (
src/columns.ts)A new runtime module (loaded after
ir.js) that analyses one query statementdown to column level:
colParseSources/colRegionsOf/colSplitArms):parses the projection and FROM regions of each
SELECTarm, splittingcomma-separated sources and
JOIN/APPLYitems, and records each source'salias, underlying name, kind (
table/cte/derived/tabfunc/opaque), provable columns, and span.WITH r(n) AS …) orcomputed projection, a derived table's projection, a tabular function's
column-alias list, and catalogue columns (
catalogueColumnsForviaresolveCatalogue) turn intocolumnsKnownscope entries. Plain tableswithout catalogue evidence stay
columnsKnown: false(conservative).colBind): qualified references bind to the exact scope key;unqualified references bind only when exactly one candidate exists. Multiple
candidates →
column_ambiguous(region-scoped, span-attached, no bindinginvented); zero candidates, unknown qualifiers, missing columns in a
provable scope, and scalar subqueries →
column_opaque.colParseItems/colScanRefs): aliases (ASandbare trailing), expression-level provenance (
s.a + s.b AS totalmapstotalto both inputs),COUNT(*)row aggregates (no invented column), andpredicate references (WHERE / GROUP BY / HAVING / ORDER BY / JOIN ON /
USING) all bind with spans.
*/t.*expand only when the catalogue (or a provablescope) proves every contributing source's columns; otherwise they are
recorded unexpanded and never invent columns.
analyseColumns(toks, opts)is the public entry point; every region-scopeddiagnostic carries a valid source span.
Analysis integration (
src/ir.ts)analyse()now walks the AST and column-analyses every query-bearingSELECTstatement (including inside control flow), attaches the results as
result.columns: ColumnLineage[], and merges the region-scopedcolumn_ambiguous/column_opaquediagnostics into the findings panel.Confidence, coverage, graphs, exports, and construct coverage are untouched:
clean queries produce no new diagnostics, so all existing object-level
fixtures remain green.
Types (
src/types.d.ts)ColumnSource,ColumnOutput,ColumnBinding,ColumnWildcard,ColumnReference,ColumnLineage,ColumnResolution,ColumnSourceKind;AnalysisResult.columns;PROCFLOW_COLUMN_PASS/_RESULT/_DETAILglobals.
Fixtures and tests
tests/columns.ts(+tests/index.html,tests/metrics.html, andcolumns.jswiring) — 18 fixture-corpus records plus 3 integration recordscovering qualified/unqualified bindings, aliases, JOIN predicates,
expression provenance, CTE scopes (explicit + computed), derived tables,
catalogue-backed wildcard expansion (qualified and bare
*), unexpandedwildcards without catalogue, scalar-subquery opacity, out-of-scope
references, WHERE predicates, recursive-CTE bindings,
DISTINCT TOP, andSELECT … INTO, plus theanalyse()integration (attach + findings) andthe clean-binding/no-noise guard. Gates the golden page via
PROCFLOW_COLUMN_PASS.tests/tests.ts— gates the golden page on the column suite.tests/metrics.ts→docs/metrics-v1.10.0.json— addscolumnPassRateandthe
columnscorpus count (18/18); the v1.9.0 snapshot is renamed tov1.10.0 (old snapshot removed).
examples/dbo.v1100_demo.sql— a view + procedure + audit demo showing CTEscopes, qualified/alias bindings, expression provenance, derived tables, the
ambiguous reference diagnostic, the opaque subquery diagnostic, and
catalogue-backed wildcard expansion (with a catalogue to paste).
Verification
npm run typecheck— passesnpm run build— passesnpm run test:file— passes (withCHROME_PATHset)npm run metrics— snapshot is current;docs/metrics-v1.10.0.jsoncommitted (v1.9.0 snapshot renamed), 100 % column pass rate
dist/committed in sync (addsdist/src/columns.jsanddist/tests/columns.js)Not changed / deferred (per roadmap)
flow, inter-object column flow through CTE/view boundaries, column export
parity/round-trip and layout, and RDL/report import — is out of scope.
docs/metrics-v1.10.0.jsonare byte-identical to v1.9.0's for everypre-existing metric, confirming no parser regression, and the full golden
suite stays green.