Skip to content

Commit 2f753d9

Browse files
committed
Fix error counts for exposures
1 parent e4d5a4e commit 2f753d9

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Under the Hood
2+
body: Fix error counts for exposures
3+
time: 2025-01-10T20:20:57.01632Z
4+
custom:
5+
Author: aranke
6+
Issue: ' '

Diff for: core/dbt/task/printer.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Dict, Optional, Union
22

33
from dbt.artifacts.schemas.results import NodeStatus
4+
from dbt.contracts.graph.nodes import Exposure
45
from dbt.events.types import (
56
CheckNodeTestFailure,
67
EndOfRunSummary,
@@ -83,7 +84,9 @@ def print_run_result_error(
8384
node_info = None
8485
if hasattr(result, "node") and result.node:
8586
node_info = result.node.node_info
86-
if result.status == NodeStatus.Fail or (is_warning and result.status == NodeStatus.Warn):
87+
if result.status in (NodeStatus.Fail, NodeStatus.Error) or (
88+
is_warning and result.status == NodeStatus.Warn
89+
):
8790
if newline:
8891
fire_event(Formatting(""))
8992
if is_warning:
@@ -115,11 +118,11 @@ def print_run_result_error(
115118
else:
116119
fire_event(RunResultErrorNoMessage(status=result.status, node_info=node_info))
117120

118-
if result.node.compiled_path is not None:
121+
if getattr(result.node, "compiled_path", None):
119122
fire_event(Formatting(""))
120123
fire_event(SQLCompiledPath(path=result.node.compiled_path, node_info=node_info))
121124

122-
if result.node.should_store_failures:
125+
if getattr(result.node, "should_store_failures", None):
123126
fire_event(Formatting(""))
124127
fire_event(
125128
CheckNodeTestFailure(relation_name=result.node.relation_name, node_info=node_info)
@@ -139,10 +142,13 @@ def print_run_end_messages(results, keyboard_interrupt: bool = False) -> None:
139142
for r in results:
140143
if r.status in (NodeStatus.RuntimeErr, NodeStatus.Error, NodeStatus.Fail):
141144
errors.append(r)
142-
elif r.status == NodeStatus.Skipped and r.message is not None:
143-
# this means we skipped a node because of an issue upstream,
144-
# so include it as an error
145-
errors.append(r)
145+
elif r.status == NodeStatus.Skipped and r.message:
146+
if isinstance(r.node, Exposure):
147+
# Don't include exposure skips in errors list
148+
continue
149+
else:
150+
# This means we skipped a node because of an issue upstream, so include it as an error
151+
errors.append(r)
146152
elif r.status == NodeStatus.Warn:
147153
warnings.append(r)
148154
elif r.status == NodeStatus.PartialSuccess:

Diff for: core/dbt/task/runnable.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from dbt.cli.flags import Flags
2424
from dbt.config.runtime import RuntimeConfig
2525
from dbt.contracts.graph.manifest import Manifest
26-
from dbt.contracts.graph.nodes import ResultNode
26+
from dbt.contracts.graph.nodes import Exposure, ResultNode
2727
from dbt.contracts.state import PreviousState
2828
from dbt.events.types import (
2929
ArtifactWritten,
@@ -619,19 +619,19 @@ def interpret_results(cls, results):
619619
if results is None:
620620
return False
621621

622-
failures = [
623-
r
624-
for r in results
625-
if r.status
626-
in (
627-
NodeStatus.RuntimeErr,
628-
NodeStatus.Error,
629-
NodeStatus.Fail,
630-
NodeStatus.Skipped, # propogate error message causing skip
631-
NodeStatus.PartialSuccess, # because partial success also means partial failure
632-
)
633-
]
634-
return len(failures) == 0
622+
num_runtime_errors = len([r for r in results if r.status == NodeStatus.RuntimeErr])
623+
num_errors = len([r for r in results if r.status == NodeStatus.Error])
624+
num_fails = len([r for r in results if r.status == NodeStatus.Fail])
625+
num_skipped = len(
626+
[
627+
r
628+
for r in results
629+
if r.status == NodeStatus.Skipped and not isinstance(r.node, Exposure)
630+
]
631+
)
632+
num_partial_success = len([r for r in results if r.status == NodeStatus.PartialSuccess])
633+
num_total = num_runtime_errors + num_errors + num_fails + num_skipped + num_partial_success
634+
return num_total == 0
635635

636636
def get_model_schemas(self, adapter, selected_uids: Iterable[str]) -> Set[BaseRelation]:
637637
if self.manifest is None:

Diff for: tests/unit/test_events.py

+3
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ def test_single_run_error():
575575
class MockNode:
576576
unique_id: str = ""
577577
node_info = None
578+
resource_type: str = "model"
579+
name: str = "my_model"
580+
original_file_path: str = "path/to/model.sql"
578581

579582
error_result = RunResult(
580583
status=RunStatus.Error,

0 commit comments

Comments
 (0)