Skip to content

Commit

Permalink
Use SourceFreshnessRuntimeError
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Mar 14, 2024
1 parent bd873eb commit 1dfe290
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/dbt/artifacts/schemas/freshness/v3/freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
BaseArtifactMetadata,
)
from dbt_common.dataclass_schema import dbtClassMixin, StrEnum
from dbt_common.exceptions import DbtInternalError, DbtRuntimeError
from dbt_common.exceptions import DbtInternalError

from dbt.contracts.graph.nodes import SourceDefinition

Expand Down Expand Up @@ -94,7 +94,7 @@ class FreshnessErrorEnum(StrEnum):

@dataclass
class SourceFreshnessRuntimeError(dbtClassMixin):
unique_id: str
unique_id: Optional[str]
error: Optional[Union[str, int]]
status: FreshnessErrorEnum

Expand All @@ -114,11 +114,6 @@ class FreshnessExecutionResultArtifact(

@classmethod
def from_result(cls, base: FreshnessResult):
# Raise an error if a hook failed
for r in base.results:
if isinstance(r, BaseResult) and r.status == RunStatus.Error:
raise DbtRuntimeError(r.message)

processed = [process_freshness_result(r) for r in base.results]
return cls(
metadata=base.metadata,
Expand All @@ -128,7 +123,15 @@ def from_result(cls, base: FreshnessResult):


def process_freshness_result(result: FreshnessNodeResult) -> FreshnessNodeOutput:
if isinstance(result, BaseResult) and result.status == RunStatus.Error:
return SourceFreshnessRuntimeError(

Check warning on line 127 in core/dbt/artifacts/schemas/freshness/v3/freshness.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/artifacts/schemas/freshness/v3/freshness.py#L127

Added line #L127 was not covered by tests
unique_id=None,
error=result.message + "foobar",
status=FreshnessErrorEnum.runtime_error,
)

unique_id = result.node.unique_id

if result.status == FreshnessStatus.RuntimeErr:
return SourceFreshnessRuntimeError(
unique_id=unique_id,
Expand Down

0 comments on commit 1dfe290

Please sign in to comment.