Merged PR 1923: User Currency

- Ingest the currency table from the backend into DWH.
- Add the newly created `AccountCurrencyId` into the `User` table.
- Push the data to the intermediate user model while replacing the internal superhog currency ID by the ISO4217 code so it's easily joinable with other stuff.

Now, every money amount related to some user in the SQL server backend can be currency-informed instead of currency-less.
This commit is contained in:
Pablo Martín 2024-05-24 10:03:00 +00:00
commit b59c0a96fb
4 changed files with 26 additions and 4 deletions

View file

@ -1,8 +1,12 @@
with with
stg_core__user as (select * from {{ ref("stg_core__user") }}), stg_core__user as (select * from {{ ref("stg_core__user") }}),
stg_core__superhog_user as (select * from {{ ref("stg_core__superhog_user") }}) stg_core__superhog_user as (select * from {{ ref("stg_core__superhog_user") }}),
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
select select
id_user, id_user,
id_account_type,
id_billing_country,
c.iso4217_code as account_currency_iso4217,
user_code, user_code,
first_name, first_name,
last_name, last_name,
@ -38,3 +42,4 @@ select
id_user_verification_status id_user_verification_status
from stg_core__user as u from stg_core__user as u
inner join stg_core__superhog_user as su on u.id_user = su.id_superhoguser inner join stg_core__superhog_user as su on u.id_user = su.id_superhoguser
left join stg_core__currency c on u.id_account_currency = c.id_currency

View file

@ -199,4 +199,6 @@ sources:
identifier: PricePlanToUser identifier: PricePlanToUser
- name: PricePlanChargedByType - name: PricePlanChargedByType
identifier: PricePlanChargedByType identifier: PricePlanChargedByType
- name: Currency
identifier: Currency

View file

@ -0,0 +1,14 @@
with
raw_currency as (select * from {{ source("core", "Currency") }}),
stg_core__currency as (
select
{{ adapter.quote("Id") }} as id_currency,
{{ adapter.quote("Name") }} as currency_name,
{{ adapter.quote("IsoCode") }} as iso4217_code,
{{ adapter.quote("DisplayOrder") }} as display_order,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extract_at_utc
from raw_currency
)
select *
from stg_core__currency

View file

@ -5,6 +5,10 @@ with
stg_core__user as ( stg_core__user as (
select select
{{ adapter.quote("Id") }} as id_user, {{ adapter.quote("Id") }} as id_user,
{{ adapter.quote("AccountTypeId") }} as id_account_type,
{{ adapter.quote("CreatedUserId") }} as id_created_user,
{{ adapter.quote("BillingCountryId") }} as id_billing_country,
{{ adapter.quote("AccountCurrencyId") }} as id_account_currency,
{{ adapter.quote("Code") }} as user_code, {{ adapter.quote("Code") }} as user_code,
{{ adapter.quote("Email") }} as email, {{ adapter.quote("Email") }} as email,
{{ adapter.quote("Title") }} as title, {{ adapter.quote("Title") }} as title,
@ -21,13 +25,10 @@ with
cast({{ adapter.quote("DateOfBirth") }} as date) as date_of_birth, cast({{ adapter.quote("DateOfBirth") }} as date) as date_of_birth,
{{ adapter.quote("PhoneNumber") }} as phone_number, {{ adapter.quote("PhoneNumber") }} as phone_number,
{{ adapter.quote("PasswordHash") }} as password_hash, {{ adapter.quote("PasswordHash") }} as password_hash,
{{ adapter.quote("AccountTypeId") }} as id_account_type,
{{ adapter.quote("CreatedUserId") }} as id_created_user,
{{ adapter.quote("SecurityStamp") }} as security_stamp, {{ adapter.quote("SecurityStamp") }} as security_stamp,
{{ adapter.quote("EmailConfirmed") }} as is_email_confirmed, {{ adapter.quote("EmailConfirmed") }} as is_email_confirmed,
{{ adapter.quote("LockoutEnabled") }} as is_lockout_enabled, {{ adapter.quote("LockoutEnabled") }} as is_lockout_enabled,
{{ adapter.quote("BillingPostcode") }} as billing_postcode, {{ adapter.quote("BillingPostcode") }} as billing_postcode,
{{ adapter.quote("BillingCountryId") }} as id_billing_country,
{{ adapter.quote("TwoFactorEnabled") }} as is_twofactor_enabled, {{ adapter.quote("TwoFactorEnabled") }} as is_twofactor_enabled,
{{ adapter.quote("AccessFailedCount") }} as access_failed_count, {{ adapter.quote("AccessFailedCount") }} as access_failed_count,
{{ adapter.quote("LockoutEndDateUtc") }} as lockout_end_date_utc, {{ adapter.quote("LockoutEndDateUtc") }} as lockout_end_date_utc,