From 83f0f46196763c40507f27f3ff2f63eeb49da6c0 Mon Sep 17 00:00:00 2001 From: Noy Arie Date: Wed, 27 Sep 2023 19:39:58 +0300 Subject: [PATCH] add to freshness result criteria (#551) --- macros/edr/dbt_artifacts/upload_source_freshness.sql | 4 ++++ macros/edr/system/system_utils/empty_table.sql | 5 ++++- models/edr/alerts/alerts_dbt_source_freshness.sql | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/macros/edr/dbt_artifacts/upload_source_freshness.sql b/macros/edr/dbt_artifacts/upload_source_freshness.sql index 9acc3fdbe..81eaf887c 100644 --- a/macros/edr/dbt_artifacts/upload_source_freshness.sql +++ b/macros/edr/dbt_artifacts/upload_source_freshness.sql @@ -23,6 +23,7 @@ {% endif %} {% endfor %} {% set metadata_dict = elementary.safe_get_with_default(node_dict, 'metadata', {}) %} + {% set criteria_dict = elementary.safe_get_with_default(node_dict, 'criteria', {}) %} {% set source_freshness_invocation_id = metadata_dict.get('invocation_id', invocation_id) %} {% set flatten_source_freshness_dict = { 'source_freshness_execution_id': [source_freshness_invocation_id, node_dict.get('unique_id')] | join('.'), @@ -32,6 +33,9 @@ 'max_loaded_at_time_ago_in_s': node_dict.get('max_loaded_at_time_ago_in_s'), 'status': node_dict.get('status'), 'error': node_dict.get('error'), + 'warn_after': criteria_dict.get('warn_after'), + 'error_after': criteria_dict.get('error_after'), + 'filter': criteria_dict.get('filter'), 'generated_at': elementary.datetime_now_utc_as_string(), 'invocation_id': source_freshness_invocation_id, 'compile_started_at': compile_timing.get('started_at'), diff --git a/macros/edr/system/system_utils/empty_table.sql b/macros/edr/system/system_utils/empty_table.sql index 48407b02c..e765096c4 100644 --- a/macros/edr/system/system_utils/empty_table.sql +++ b/macros/edr/system/system_utils/empty_table.sql @@ -46,7 +46,10 @@ ('compile_completed_at', 'string'), ('execute_started_at', 'string'), ('execute_completed_at', 'string'), - ('invocation_id', 'string') + ('invocation_id', 'string'), + ('warn_after', 'string'), + ('error_after', 'string'), + ('filter', 'long_string') ]) }} {% endmacro %} diff --git a/models/edr/alerts/alerts_dbt_source_freshness.sql b/models/edr/alerts/alerts_dbt_source_freshness.sql index 18345b64d..d33dc1334 100644 --- a/models/edr/alerts/alerts_dbt_source_freshness.sql +++ b/models/edr/alerts/alerts_dbt_source_freshness.sql @@ -21,14 +21,14 @@ select results.max_loaded_at_time_ago_in_s, results.status, results.error, + results.warn_after, + results.error_after, + results.filter, sources.unique_id, sources.database_name, sources.schema_name, sources.source_name, sources.identifier, - sources.freshness_error_after, - sources.freshness_warn_after, - sources.freshness_filter, sources.tags, sources.meta, sources.owner,