-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ele 1484 source freshness invocation (#1165)
* fix typo * add metadata * validate invocation id * renaming and refactor * remove falsy condition
- Loading branch information
Showing
3 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
elementary/monitor/dbt_project/macros/can_upload_source_freshness.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% macro can_upload_source_freshness(invocation_id, days_back=14) %} | ||
{% set counter_query %} | ||
with invocations as ( | ||
select invocation_id | ||
from {{ ref("elementary", "dbt_source_freshness_results") }} | ||
where {{ elementary.edr_datediff(elementary.edr_cast_as_timestamp('generated_at'), elementary.edr_current_timestamp(), 'day') }} < {{ days_back }} | ||
) | ||
select count(*) as count | ||
from invocations | ||
where invocation_id = {{ elementary.edr_quote(invocation_id) }} | ||
{% endset %} | ||
|
||
{% set records_count = elementary.result_value(counter_query) %} | ||
|
||
{% if records_count == 0 %} | ||
{% do return(true) %} | ||
{% endif %} | ||
{% do return(none) %} | ||
{% endmacro %} |
4 changes: 2 additions & 2 deletions
4
elementary/monitor/dbt_project/macros/upload_source_freshness.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% macro upload_source_freshness(results) %} | ||
{% set source_freshness_results_dicts = fromjson(results) %} | ||
{% set source_freshness_results = fromjson(results) %} | ||
{% set source_freshness_results_relation = ref('dbt_source_freshness_results') %} | ||
{% do elementary.upload_artifacts_to_table(source_freshness_results_relation, source_freshness_results_dicts, elementary.flatten_source_freshness, append=True, should_commit=true) %} | ||
{% do elementary.upload_artifacts_to_table(source_freshness_results_relation, source_freshness_results, elementary.flatten_source_freshness, append=True, should_commit=true) %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters