Skip to content

Commit e80cf4c

Browse files
hkaltaiclaude
andcommitted
refactor: the column-name scan runs once per model; test rules out a certain reader for a constant model
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fe673cf commit e80cf4c

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎packages/opencode/src/altimate/native/dbt/column-reach.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,15 @@ export function columnReach(manifestPath: string, model: string, column: string,
322322
uncertain.push(entry(id, "reads an ephemeral parent, inlined as a CTE the lineage engine cannot trace through"))
323323
continue
324324
}
325+
const named = parents.flatMap((parent) => [...tracked.get(parent)!].filter((col) => namesColumn(sqlText, col)))
325326
// No edge at all while the SQL names the column (a PIVOT, say) is the engine not seeing through
326327
// it, so its outputs are unknown. SQL that never names it (`select 1`, `count(*)`) reads nothing and
327328
// falls through. Below an unsure parent it is already reported as uncertain.
328-
if (edges.length === 0 && !fromUnsure && parents.some((p) => [...tracked.get(p)!].some((col) => namesColumn(sqlText, col)))) {
329+
if (edges.length === 0 && !fromUnsure && named.length > 0) {
329330
uncertain.push(entry(id, "names it, but the lineage engine found no column edges in its SQL"))
330331
unsure.add(id)
331332
continue
332333
}
333-
const named = parents.flatMap((parent) => [...tracked.get(parent)!].filter((col) => namesColumn(sqlText, col)))
334334
const shared = named.some((col) => allParents.filter((other) => documentedColumns(lookup(other)).has(col)).length > 1)
335335
if (ambiguous || named.length > 0 || fromUnsure) {
336336
if (ambiguous || fromUnsure) unsure.add(id)

‎packages/opencode/test/altimate/column-reach.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ describe("columnReach on a model the engine cannot fully trace", () => {
392392
try {
393393
const reach = columnReach(manifestFile(constant), "fct_orders", "revenue")
394394
expect([...reach.untraced, ...reach.uncertain].map((m) => m.name)).not.toContain("rpt_ltv")
395+
expect(reach.models.map((m) => m.name)).not.toContain("rpt_ltv")
395396
} finally {
396397
again.mockRestore()
397398
}

0 commit comments

Comments
 (0)