Skip to content

Commit

Permalink
Merge pull request #64 from get-select/dev
Browse files Browse the repository at this point in the history
Increase incremental lookback window to account for changing cost data
  • Loading branch information
ian-whitestone authored Jan 7, 2023
2 parents 4166fc7 + af04834 commit b8fa77a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230106-215452.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Increase incremental lookback window to account for changing cost data
time: 2023-01-06T21:54:52.198505-07:00
custom:
Author: ian-whitestone
PR: "64"
10 changes: 7 additions & 3 deletions models/query_history_enriched.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ config(materialized='incremental') }}
{{ config(materialized='incremental', unique_key=['query_id', 'start_time']) }}

with
query_history as (
Expand All @@ -16,15 +16,19 @@ query_history as (
from {{ ref('stg_query_history') }}

{% if is_incremental() %}
where end_time > (select max(end_time) from {{ this }})
-- Conservatively re-process the last 7 days to account for late arriving rates data
-- which changes the cost per query
where end_time > (select dateadd(day, -7, max(end_time)) from {{ this }})
{% endif %}
),

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

Expand Down

0 comments on commit b8fa77a

Please sign in to comment.