feat: fan out multi-column-alias lineage to every alias#60
Merged
Conversation
Contributor
|
✅ PR title follows the Conventional Commits spec. |
f36cdbd to
bf24a2f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #60 +/- ##
==========================================
- Coverage 94.85% 94.84% -0.01%
==========================================
Files 27 27
Lines 5737 5747 +10
Branches 5737 5747 +10
==========================================
+ Hits 5442 5451 +9
Misses 216 216
- Partials 79 80 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
8702d35 to
1cdb66b
Compare
Spark's `expr AS (a, b, …)` projects one expression under several output names. Lineage used to reach only the first alias (`explode(t.arr) AS (k, v)` emitted `arr → k` alone); it now fans out — every alias gets its own edge from the expression's sources, with the head expression's kind (`Transformation` for a call, `Passthrough` for a bare column). The IR models the fan as **one item**: `NamedExpr` gains `names: OutputNames` (`Single(Option<Ident>)` | `Fan(Vec<Ident>)`), so the expression exists exactly once — `reads` count it once by construction, and the names can never separate from it (no reference to dangle under any reorder / filter). A fan occupies one output *position* per name, so an item index is no longer an output position: every positional / named consumer — query outputs, DML relation pairing, RETURNING, CTAS / CREATE VIEW, set-operation / scalar-subquery / EXCLUDED traces, derived-table name traces, output-column scopes, `AS d(x, y)` renames, arity checks — goes through one slot view (`output_slots` / `slot_count` / `resolved_output_expr`), where the fan expands. `SELECT v FROM (SELECT explode(arr) AS (k, v) FROM t) d` reaches `t.arr`; an INSERT / CTAS feeds every target column. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1cdb66b to
55b4266
Compare
Merged
takaebato
added a commit
that referenced
this pull request
Jul 5, 2026
## 🤖 New release * `sql-insight`: 0.3.0 -> 0.4.0 (✓ API compatible changes) * `sql-insight-cli`: 0.2.1 -> 0.2.2 <details><summary><i><b>Changelog</b></i></summary><p> ## `sql-insight` <blockquote> ## [0.4.0](sql-insight-v0.3.0...sql-insight-v0.4.0) - 2026-07-05 ###⚠️ Breaking Changes #### attribute unqualified SET targets with the read-side rules ([#59](#59)) by @takaebato #### upgrade sqlparser to 0.62 ([#55](#55)) by @takaebato ### Added - resolve Oracle join-view INSERT targets by column attribution ([#61](#61)) by @takaebato - fan out multi-column-alias lineage to every alias ([#60](#60)) by @takaebato - resolve Oracle inline-view INSERT targets to their base table ([#58](#58)) by @takaebato ### Fixed - don't surface a ClickHouse ARRAY JOIN operand as a table read ([#57](#57)) by @takaebato ### Other Changes - changelog breaking-change workflow, version-bump docs, and keywords ([#51](#51)) by @takaebato - tidy keywords, README versions, and add a version-sync check ([#46](#46)) by @takaebato </blockquote> ## `sql-insight-cli` <blockquote> ## [0.2.2](sql-insight-cli-v0.2.1...sql-insight-cli-v0.2.2) - 2026-07-05 ### Added - *(cli)* prebuilt binary distribution — cargo binstall, completions, man, and provenance ([#53](#53)) by @takaebato ### Fixed - *(deps)* update rust crate clap_mangen to 0.3 ([#54](#54)) by @renovate[bot] ### Other Changes - changelog breaking-change workflow, version-bump docs, and keywords ([#51](#51)) by @takaebato - tidy keywords, README versions, and add a version-sync check ([#46](#46)) by @takaebato </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Takahiro Ebato <takahiro.ebato@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Implements the last follow-up noted in #55 (design agreed in discussion):
lineage for Spark's multi-column alias
expr AS (a, b, …)now fans out toevery alias instead of stopping at the first.
Design: the fan is one item (no references)
NamedExprgainsnames: OutputNames—Single(Option<Ident>)for anordinary item,
Fan(Vec<Ident>)for a multi-column alias:readscount it once byconstruction (occurrence-based, unchanged), and item walks (
own_exprs)stay a plain map.
back-reference to dangle under any reorder / filter / splice (the design
review rejected a positional
Fanout { back }reference and adebug_assert-guarded fallback for exactly this reason).through one slot view (
output_slots/slot_count/resolved_output_expr), where a fan yields its shared expression once pername — query-output lineage, INSERT positional pairing, RETURNING, CTAS /
CREATE VIEW, the shared positional trace (set-op branches, scalar
subqueries,
EXCLUDED), derived-table name traces, output-column scopes(
OutputCol, fan outputs are never identity),AS d(x, y)positionalrenames, and the created-columns / insert arity checks.
explode(arr)fans outTransformations; a bare columnt.a AS (x, y)fans outPassthroughs.Non-breaking: output shapes are unchanged; lineage gains edges (the
first-alias-only behavior was a documented best-effort in #55, not a
contract).
Verified end-to-end: fan-out for 2 aliases,
Passthroughfan-out for a barecolumn, the tail alias traced through a derived table, INSERT pairing and
CTAS / CREATE VIEW feeding every target column, positional fan renames through
a derived alias list (
AS d(x, y)) and a CTE column list, UNION branchestracing positionally (existing reads-once pins unchanged). All gates green
(fmt / clippy /
test --all/ doc); 766 tests, 100% patch coverage(llvm-cov ∩ diff).
🤖 Generated with Claude Code