Skip to content

Commit

Permalink
Raise error when loaded_at_field is None and metadata check isn't…
Browse files Browse the repository at this point in the history
… possible

Previously if a source freshness check didn't have a `loaded_at_field` and
metadata source freshness wasn't supported by the adapter, then we'd log
a warning message and let the source freshness check continue. This was problematic
because the source freshness check couldn't actually continue and the process
would raise an error in the form
```
type object argument after ** must be a mapping, not NoneType
```
because the `freshness` variable was never getting set. This error wasn't particularly
helpful for any person running into it. So instead of letting that error
happen we now deliberately raise an error with helpful information.
  • Loading branch information
QMalcolm committed Mar 26, 2024
1 parent 7ec2f82 commit a162d53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/dbt/task/freshness.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ def execute(self, compiled_node, manifest):

status = compiled_node.freshness.status(freshness["age"])
else:
status = FreshnessStatus.Warn
fire_event(Note(msg=f"Skipping freshness for source {compiled_node.name}."))
raise DbtRuntimeError(
f"Could not compute freshness for source {compiled_node.name}: no 'loaded_at_field' provided and {self.adapter.type()} adapter does not support metadata-based freshness checks."
)

# adapter_response was not returned in previous versions, so this will be None
# we cannot call to_dict() on NoneType
Expand Down

0 comments on commit a162d53

Please sign in to comment.