feat(sql-plan): composite/instance-bound joins, aggregate_source, deterministic emission, final_dedup latest - #22
Merged
dmautz1 merged 9 commits intoAug 31, 2026
Conversation
join_conditions on OutgoingRelationship append AND-ed equalities to the direct-join ON clause (each side a plain column or an expression, rewritten like the primary key pair: base side against the accumulated view, target side against the joined table; referenced base columns reach the base view). join_type gains 'full_outer' — emitted as FULL OUTER JOIN and forcing the direct strategy (fan-out preserved on both sides) regardless of cardinality notation. Direct joins only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
table_instance on OutgoingRelationship binds the relationship to a single named instance: each bound relationship supplies its own join keys/ conditions, so the same table can join twice under different aliases (rule-table pattern: det_any keyed on determination, det_triple keyed on the stage/status/reason triple). Unbound relationships keep applying to every candidate-declared instance. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…table base_table_strategy: aggregate_source emits disposition_base as a GROUP BY over base_table: plain candidates form the group key(s), expression candidates (aggregates — SUM/MIN_BY/…) project under their target physical names, and final assembly passes everything through. The third leg of the aggregate story (side-agg join, pre-agg views, now aggregation-native). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…equirement attribution Squash of six small fixes to the base-view / join-projection column requirement pass: - prefixed intermediate refs (alias__col) reach the join projection, attributed to the real table (673a911) - a leading-underscore canonical_name emits the physical column; final assembly aliases with it, matching the DDL exporter (3ebb131) - prefixed-ref attribution runs for every expression, not only when the candidate lacks a plain column (96292a5) - tables referenced only via prefixed refs keep their join (72fb62c) - _get_table_columns returns physical names so base view, join projections, requirement matching, and expression rewriting agree (6e450b1) - intermediate-referenced base columns reach the base view (edae7b6) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tic output _required_columns holds sets; iterating one directly leaked the process hash seed into the base view's emitted column order, flipping plan bytes between runs (observed: EntryDt/ID swap in a downstream consumer's silver_service_line_billing plan). Byte-stable output is required for regenerate-and-diff commit gates over checked-in generated SQL. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…at final assembly Extends metadata.final_dedup with a keyed variant: QUALIFY ROW_NUMBER() OVER (PARTITION BY final_dedup_keys ORDER BY final_dedup_order_by) = 1 wrapped around the final assembly (composes with final_filter). Rows with a NULL in any dedup key pass through undeduplicated — identity cannot be asserted without a key, and PARTITION BY would otherwise collapse ALL null-key rows into one survivor. New metadata fields: final_dedup_keys (defaults to primary_key) and final_dedup_order_by (required). Motivation: grain contracts on conformed silver feeds — enforce 'one row per declared key' at the table that owns the grain instead of bolting dedupe CTEs onto every consumer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Records the sql-plan capabilities ported from production (PRs DocumentDrivenDX#18/DocumentDrivenDX#19 and the composite stack) as source-backed scope evidence on FEAT-019, and refreshes the registry row. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Completes the production sql-plan port on top of #18/#19 — this is the remainder of the fork stack a production deployment currently pins (
0320fe6), rebased onto main and restructured for review.Features
join_conditions(AND-ed column/expression equalities) +join_type: full_outer, which forces the direct strategy regardless of cardinality notationtable_instancebinds a relationship to one named instance, so the same table joins twice under different keys (rule-table pattern)base_table_strategy: aggregate_source— the GROUP BY is the table (third leg of the aggregate story)final_dedup: latest— declared-grainQUALIFY ROW_NUMBER() = 1at final assembly withfinal_dedup_keys/final_dedup_order_by; rows with a NULL dedup key pass through undeduplicatedFixes
Docs
Full local gate passes: format-check, lint, type-check, 3854 tests including DuckDB/Spark conformance.
🤖 Generated with Claude Code