From a162d53a8f3e1489ac9149a6030f74383d228434 Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Tue, 26 Mar 2024 15:36:43 -0700 Subject: [PATCH] Raise error when `loaded_at_field` is `None` and metadata check isn't 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. --- core/dbt/task/freshness.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/dbt/task/freshness.py b/core/dbt/task/freshness.py index 4b32902b1ec..ed37a9e19f1 100644 --- a/core/dbt/task/freshness.py +++ b/core/dbt/task/freshness.py @@ -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