Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override of incremental look-back period #140

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions models/dbt_queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ select
from {{ ref('query_history_enriched') }}
where dbt_metadata is not null
{% if is_incremental() %}
-- Conservatively re-process the last 3 days to account for late arriving rates data
-- which changes the cost per query
and end_time > (select dateadd(day, -3, max(end_time)) from {{ this }})
-- Conservatively re-process the last 3 days to account for late arriving rates data which changes the cost per query.
-- Allow an override from project variable
and end_time > (select dateadd(day, -{{ var('dbt_snowflake_monitoring_incremental_days', '3') }}, max(end_time)) from {{ this }})
{% endif %}
2 changes: 1 addition & 1 deletion models/dbt_queries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

models:
- name: dbt_queries
description: Filtered version of query_history_enriched just for queries issued by dbt. Adds additional dbt-specific columns.
description: Filtered version of query_history_enriched just for queries issued by dbt. Adds additional dbt-specific columns. Incrementally pulls the last 3 days by default to account for late arriving rates data. This can be overriden by passing a value for dbt_snowflake_monitoring_incremental_days.
columns:
- name: dbt_snowflake_query_tags_version
description: Version of the dbt-snowflake-query-tags package that generated the metadata
Expand Down
8 changes: 4 additions & 4 deletions models/query_history_enriched.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ query_history as (
from {{ ref('stg_query_history') }}

{% if is_incremental() %}
-- Conservatively re-process the last 3 days to account for late arriving rates data
-- Conservatively re-process the last 3 days to account for late arriving rates data. Allow an override from project variable
-- which changes the cost per query
where end_time > (select dateadd(day, -3, max(end_time)) from {{ this }})
where end_time > (select dateadd(day, -{{ var('dbt_snowflake_monitoring_incremental_days', '3') }}, max(end_time)) from {{ this }})
{% endif %}
),

cost_per_query as (
select *
from {{ ref('cost_per_query') }}
{% if is_incremental() %}
-- Conservatively re-process the last 3 days to account for late arriving rates data
-- Conservatively re-process the last 3 days to account for late arriving rates data. Allow an override from project variable
-- which changes the cost per query
where end_time > (select dateadd(day, -3, max(end_time)) from {{ this }})
where end_time > (select dateadd(day, -{{ var('dbt_snowflake_monitoring_incremental_days', '3') }}, max(end_time)) from {{ this }})
{% endif %}
)

Expand Down
Loading