diff --git a/models/staging/stripe/stg_stripe__balance_transactions.sql b/models/staging/stripe/stg_stripe__balance_transactions.sql index 7bf4287..da82a35 100644 --- a/models/staging/stripe/stg_stripe__balance_transactions.sql +++ b/models/staging/stripe/stg_stripe__balance_transactions.sql @@ -14,7 +14,6 @@ with union all {%- endif %} {% endfor %} - ), stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}), stg_stripe__balance_transactions as ( diff --git a/models/staging/stripe/stg_stripe__charges.sql b/models/staging/stripe/stg_stripe__charges.sql index 208608e..4e06e42 100644 --- a/models/staging/stripe/stg_stripe__charges.sql +++ b/models/staging/stripe/stg_stripe__charges.sql @@ -1,5 +1,20 @@ with - raw_charges as (select * from {{ source("stripe_uk", "charges") }}), + raw_charges as ( + /* + This macro runs for every country code and: + - Reads from the right source (stripe_) + - Adds a column identifying the source account with a string like "stripe__account" + */ + {% set countries = ["us", "uk"] %} + + {% for country in countries %} + select *, 'stripe_{{ country }}_account' as stripe_source_account + from {{ source("stripe_" ~ country, "charges") }} + {% if not loop.last -%} + union all + {%- endif %} + {% endfor %} + ), stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}), stg_stripe__charges as ( select @@ -72,7 +87,8 @@ with {{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc, cast( {{ adapter.quote("_airbyte_extracted_at") }} as date - ) as dwh_extracted_date_utc + ) as dwh_extracted_date_utc, + {{ adapter.quote("stripe_source_account") }} from raw_charges ch left join