Merged PR 2039: Simple rates

- Creates a simplified rates model that hides some of the complexities of the full blown exchange rates model.

Related work items: #17212
This commit is contained in:
Pablo Martín 2024-06-14 15:33:01 +00:00
commit f900ca794f
3 changed files with 59 additions and 3 deletions

View file

@ -0,0 +1,7 @@
with
int_daily_currency_exchange_rates as (
select * from {{ ref("int_daily_currency_exchange_rates") }}
)
select er.from_currency, er.to_currency, er.rate, er.rate_date_utc, er.updated_at_utc
from int_daily_currency_exchange_rates er
where er.source = 'xedotcom' or er.source = 'xe_inferred'

View file

@ -61,11 +61,13 @@ models:
- not_null
- name: source
data_type: text
description: Where is the data coming from. Records that are composed from
description:
Where is the data coming from. Records that are composed from
making assumptions on real data will contain `_inferred`.
- name: rate_version
data_type: text
description: The version of the rate. This can be one of `actual` (the rate is a
description:
The version of the rate. This can be one of `actual` (the rate is a
reality fact), `forecast` (the rate sits in the future and is a guess
in nature) or `guess` (the rate sits in the past and is a guess in
nature). Note that one currency pair can have multiple rate versions
@ -79,7 +81,52 @@ models:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
description: For external sources, this will be the point in time when the
description:
For external sources, this will be the point in time when the
information was obtained from them. For stuff we make up here in the
DWH, this will be the point in time when we made the assumption.
tests:
- not_null
- name: int_simple_exchange_rates
description: >-
A simplified vision of exchange rates, derived from
`int_daily_currency_exchange_rates`. Come here if you don't want to
understand nuances and complexities and just want to convert rates.
The time granularity is daily. Each record holds a currency pair for a
specific day. You will only find one conversion rate per currency pair and
date.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- from_currency
- to_currency
- rate_date_utc
columns:
- name: from_currency
data_type: character
description: The source currency, represented as an ISO 4217 code.
tests:
- not_null
- name: to_currency
data_type: character
description: The source currency, represented as an ISO 4217 code.
tests:
- not_null
- name: rate
data_type: numeric
description: The target currency, represented as an ISO 4217 code.
tests:
- not_null
- name: rate_date_utc
data_type: date
description: The date in which the rate record is relevant.
tests:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
description:
For external sources, this will be the point in time when the
information was obtained from them. For stuff we make up here in the
DWH, this will be the point in time when we made the assumption.
tests:

View file

@ -3,3 +3,5 @@ packages:
version: 0.12.1
- package: calogica/dbt_expectations
version: [">=0.9.0", "<0.10.0"]
- package: dbt-labs/dbt_utils
version: 1.2.0