From 78761aa59249a6b23106ade218f98db8e766683b Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:29:45 +0200 Subject: [PATCH] Fix case when freshness set to null and add test --- integration_tests/models/staging/source_1/source.yml | 3 +-- macros/unpack/get_source_values.sql | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/integration_tests/models/staging/source_1/source.yml b/integration_tests/models/staging/source_1/source.yml index 35f5eb02..dda51887 100644 --- a/integration_tests/models/staging/source_1/source.yml +++ b/integration_tests/models/staging/source_1/source.yml @@ -16,8 +16,7 @@ sources: - name: table_2 - name: table_4 - name: table_5 - freshness: # default freshness - warn_after: null + freshness: null - name: raw_table_5 identifier: table_5 diff --git a/macros/unpack/get_source_values.sql b/macros/unpack/get_source_values.sql index 7c026dd3..00b5f5cc 100644 --- a/macros/unpack/get_source_values.sql +++ b/macros/unpack/get_source_values.sql @@ -24,8 +24,8 @@ "cast(" ~ dbt_project_evaluator.is_not_empty_string(node.description) | trim ~ " as boolean)", "cast(" ~ node.config.enabled ~ " as boolean)", wrap_string_with_quotes(node.loaded_at_field | replace("'", "_")), - "cast(" ~ (dbt_project_evaluator.is_not_empty_string(node.freshness.warn_after.count) - or dbt_project_evaluator.is_not_empty_string(node.freshness.error_after.count)) | trim ~ " as boolean)", + "cast(" ~ ((node.freshness != None) and (dbt_project_evaluator.is_not_empty_string(node.freshness.warn_after.count) + or dbt_project_evaluator.is_not_empty_string(node.freshness.error_after.count))) | trim ~ " as boolean)", wrap_string_with_quotes(node.database), wrap_string_with_quotes(node.schema), wrap_string_with_quotes(node.package_name),