Skip to content

Commit e4bed59

Browse files
anandgupta42claude
andcommitted
fix: always show check examples, filter tests from DAG properly
- Always show example patterns in "How" column (SELECT *, cartesian joins, ...) — even when findings exist, this shows value - Filter test nodes from downstream in getDownstreamModels (check node ID prefix "test.") instead of relying on name heuristics - Expand isTestNode to catch singular tests (assert_*, test_*) - Fix test assertion for always-show examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9848113 commit e4bed59

File tree

6 files changed

+31
-14
lines changed

6 files changed

+31
-14
lines changed

dist/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24384,7 +24384,9 @@ function buildQueryProfile(profiles) {
2438424384
return lines.join("\n");
2438524385
}
2438624386
function isTestNode(name) {
24387-
return /^(not_null|unique|accepted_values|relationships|dbt_utils|dbt_expectations)_/.test(name);
24387+
if (/^(not_null|unique|accepted_values|relationships|dbt_utils|dbt_expectations)_/.test(name)) return true;
24388+
if (/^(assert|test)_/.test(name)) return true;
24389+
return false;
2438824390
}
2438924391
function buildMermaidDAG(impact) {
2439024392
const filteredDownstream = impact.downstreamModels.filter((d) => !isTestNode(d));
@@ -27702,9 +27704,10 @@ function extractValidationSummary(output) {
2770227704
const findingsCount = result?.findings?.length ?? 0;
2770327705
if (meta) {
2770427706
const methodWithContext = check === "validate" && schemaResolved && output.files_checked > 0 ? `${meta.method} against ${output.files_checked} table schemas` : meta.method;
27707+
const methodDisplay = meta.examples.length > 0 ? `${methodWithContext}: ${meta.examples.join(", ")}` : methodWithContext;
2770527708
categories[check] = {
2770627709
label: meta.ruleCount > 0 ? `${meta.label} (${meta.ruleCount} rules)` : meta.label,
27707-
method: findingsCount === 0 && meta.examples.length > 0 ? `${methodWithContext}: ${meta.examples.join(", ")}, ...` : methodWithContext,
27710+
method: methodDisplay,
2770827711
rulesChecked: meta.ruleCount,
2770927712
findingsCount,
2771027713
passed: findingsCount === 0
@@ -28856,7 +28859,9 @@ function getDownstreamModels(modelIds, manifest) {
2885628859
for (const child of children) {
2885728860
if (!visited.has(child)) {
2885828861
visited.add(child);
28859-
downstream.push(child);
28862+
if (!child.startsWith("test.")) {
28863+
downstream.push(child);
28864+
}
2886028865
queue.push(child);
2886128866
}
2886228867
}

dist/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analysis/cli-check.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,16 @@ export function extractValidationSummary(output: CheckOutput): ValidationSummary
189189
? `${meta.method} against ${output.files_checked} table schemas`
190190
: meta.method;
191191

192+
// Always show example patterns in the "How" column — this demonstrates
193+
// what we checked even when everything passes
194+
const methodDisplay =
195+
meta.examples.length > 0
196+
? `${methodWithContext}: ${meta.examples.join(", ")}`
197+
: methodWithContext;
198+
192199
categories[check] = {
193200
label: meta.ruleCount > 0 ? `${meta.label} (${meta.ruleCount} rules)` : meta.label,
194-
method:
195-
findingsCount === 0 && meta.examples.length > 0
196-
? `${methodWithContext}: ${meta.examples.join(", ")}, ...`
197-
: methodWithContext,
201+
method: methodDisplay,
198202
rulesChecked: meta.ruleCount,
199203
findingsCount,
200204
passed: findingsCount === 0,

src/context/dbt.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,12 @@ export function getDownstreamModels(modelIds: string[], manifest: DBTManifest):
171171
for (const child of children) {
172172
if (!visited.has(child)) {
173173
visited.add(child);
174-
downstream.push(child);
175-
queue.push(child);
174+
// Only include models, snapshots, and analyses — not tests
175+
// dbt node IDs follow the format: resource_type.project.name
176+
if (!child.startsWith("test.")) {
177+
downstream.push(child);
178+
}
179+
queue.push(child); // Still traverse through tests to find models beyond them
176180
}
177181
}
178182
}

src/reporting/comment.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,11 @@ export function buildQueryProfile(profiles: QueryProfile[]): string {
367367
* accepted_values_model_col__val1__val2, relationships_model_col__ref_other_
368368
*/
369369
function isTestNode(name: string): boolean {
370-
return /^(not_null|unique|accepted_values|relationships|dbt_utils|dbt_expectations)_/.test(name);
370+
// Standard dbt generic tests
371+
if (/^(not_null|unique|accepted_values|relationships|dbt_utils|dbt_expectations)_/.test(name)) return true;
372+
// Singular tests (typically start with "assert_" or "test_")
373+
if (/^(assert|test)_/.test(name)) return true;
374+
return false;
371375
}
372376

373377
/**

test/unit/cli-check.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ describe("extractValidationSummary", () => {
552552

553553
expect(summary.categories.lint.passed).toBe(false);
554554
expect(summary.categories.lint.findingsCount).toBe(2);
555-
// When findings exist, method should NOT include examples
556-
expect(summary.categories.lint.method).toBe("AST analysis");
555+
// Examples are always shown to demonstrate what was checked
556+
expect(summary.categories.lint.method).toContain("AST analysis");
557557
});
558558

559559
it("includes schema resolution info for validate category", () => {

0 commit comments

Comments
 (0)