Merged PR 2041: Fix Backward Currency Projection Bug
The CTEs that project currency rates backwards have a few mistakes that introduce additional dates in the period where we do have actual, factual rates. This PR fixes the errors that cause this.
This commit is contained in:
commit
a686c16978
1 changed files with 3 additions and 4 deletions
|
|
@ -64,7 +64,7 @@ with
|
||||||
),
|
),
|
||||||
-- CTEs for projecting backward
|
-- CTEs for projecting backward
|
||||||
oldest_xe_date_per_curr_pair as (
|
oldest_xe_date_per_curr_pair as (
|
||||||
select from_currency, to_currency, max(rate_date_utc) as oldest_date_utc
|
select from_currency, to_currency, min(rate_date_utc) as oldest_date_utc
|
||||||
from stg_xedotcom__exchange_rates
|
from stg_xedotcom__exchange_rates
|
||||||
group by 1, 2
|
group by 1, 2
|
||||||
),
|
),
|
||||||
|
|
@ -84,10 +84,9 @@ with
|
||||||
(
|
(
|
||||||
{{ var("start_date") }}::timestamp,
|
{{ var("start_date") }}::timestamp,
|
||||||
(
|
(
|
||||||
select max(most_recent_date_utc)
|
select min(oldest_date_utc) from oldest_xe_date_per_curr_pair
|
||||||
from most_recent_xe_date_per_curr_pair
|
|
||||||
)::timestamp
|
)::timestamp
|
||||||
- interval '2 days', -- we don't want to pick the last real day,
|
- interval '1 days', -- we don't want to pick the last real day,
|
||||||
'1 day'::interval
|
'1 day'::interval
|
||||||
) day_series
|
) day_series
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue