feat: hide foreign-key-only edges in model lineage
[!IMPORTANT] This bug has two alternative fixes. Ship one, close the other. Both produce the same lineage-panel result; they differ only in blast radius.
- Approach A (global filter):
AltimateAI/altimate-dbt-integration#107drops the edges inside the shared dbt-integration parser. Simplest, but changes the dependency graph for every consumer (Validate SQL, the AI impact-analysis tool, depth), not just the panel.- Approach B (annotate + scope, recommended):
AltimateAI/altimate-dbt-integration#111(library) tags the edges and this PR hides them only in the lineage panel. Other consumers keep the full graph.This PR is the extension half of Approach B.
Problem
The model lineage panel draws an upstream edge for any table referenced by a declared foreign-key constraint (for example to: ref('dim_contact')), even when the model's SQL never selects from that table. dbt records FK targets in depends_on.nodes for build ordering, so they are indistinguishable from real data-flow dependencies in the graph. Result: dimension tables appear as upstream sources of a fact even though no data flows from them.
Change
@altimateai/dbt-integration now tags each lineage edge with edgeType: "data" | "constraint" (AltimateAI/altimate-dbt-integration#111). This PR makes the model-lineage view honor that tag:
DbtLineageService.getConnectedTablesdrops edges withedgeType === "constraint".getConnectedNodeCountexcludes them so the upstream / downstream counts match what is drawn.
Scope of effect
Scoped deliberately to the lineage service. The shared graphMetaMap is untouched, so:
- Validate SQL (
getNonEphemeralParents) still fetches the complete upstream set - the MCP
getChildrenModelsimpact-analysis tool still sees FK relationships - model depth is unchanged
- column lineage is unaffected (it derives edges from compiled SQL via sqlglot, not from
depends_on)
Only the model lineage panel changes. This is the difference from Approach A (AltimateAI/altimate-dbt-integration#107), which removes the edges from the shared graph for all consumers.
Verification
tsc -p ./ --noEmitclean,eslintclean, 4 new jest unit tests (upstream / downstream hiding, untagged edge treated as data-flow, count exclusion).- E2E in code-server (docker), real dbt-duckdb parse. Fixture
fct_fk_demoreads onlycustomersand declares an FK toorders:
| Before (baseline extension) | After (this PR) |
|---|---|
![]() |
![]() |
customers and orders upstream of fct_fk_demo |
only customers, the FK-only orders edge is hidden |
Sequencing
This PR consumes the edgeType field added in AltimateAI/altimate-dbt-integration#111, so it depends on that change being merged and published. Until then CI typecheck here fails against the released @altimateai/dbt-integration (Property 'edgeType' does not exist on type 'NodeData'). Order: merge and publish #111, bump the dependency here, then this goes green. Verified locally against a build of #111.
Walkthrough
DbtLineageService now excludes foreign-key constraint edges from lineage graph outputs. The getConnectedTables and getConnectedNodeCount methods filter out nodes with edgeType === "constraint" before creating table entries or computing edge counts. Comprehensive Jest tests validate the filtering behavior across upstream/downstream traversals.
Changes
Constraint Edge Filtering
| Layer / File(s) | Summary |
|---|---|
Constraint edge filtering implementation and tests src/services/dbtLineageService.ts, src/test/suite/dbtLineageService.test.ts |
getConnectedTables filters constraint edges before aggregating table entries; getConnectedNodeCount excludes constraint edges from node counts. New test suite verifies constraint edges are hidden from upstream/downstream traversals, untagged edges default to data-flow, and internal node counting aligns with filtered views. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
- mdesmet
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main change: hiding foreign-key-only edges in model lineage. It is concise, specific, and clearly reflects the core purpose of the PR. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Description check | ✅ Passed | The PR description is comprehensive and well-structured, addressing the problem, solution, scope, testing, and verification with clear references and visual proof. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Commit unit tests in branch
feat/lineage-hide-fk-only-edges
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
✅ Tests — All Passed
cc @ralphstodomingo

