macro-out the staging model unioning

This commit is contained in:
Pablo Martin 2024-03-04 17:37:43 +01:00
parent e2655a9e06
commit 32065fba65

View file

@ -1,10 +1,20 @@
with with
raw_balance_transactions as ( raw_balance_transactions as (
select *, 'stripe_uk_account' as stripe_source_account /*
from {{ source("stripe_uk", "balance_transactions") }} This macro runs for every country code and:
union all - Reads from the right source (stripe_<country-code>)
select *, 'stripe_us_account' as stripe_source_account - Adds a column identifying the source account with a string like "stripe_<country>_account"
from {{ source("stripe_us", "balance_transactions") }} */
{% set countries = ["us", "uk"] %}
{% for country in countries %}
select *, 'stripe_{{ country }}_account' as stripe_source_account
from {{ source("stripe_" ~ country, "balance_transactions") }}
{% if not loop.last -%}
union all
{%- endif %}
{% endfor %}
), ),
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}), stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
stg_stripe__balance_transactions as ( stg_stripe__balance_transactions as (