use macro in charges

This commit is contained in:
Pablo Martin 2024-03-05 13:33:53 +01:00
parent 306e2ad970
commit bbeee7a4dc

View file

@ -1,20 +1,5 @@
with
raw_charges as (
/*
This macro runs for every country code and:
- Reads from the right source (stripe_<country-code>)
- Adds a column identifying the source account with a string like "stripe_<country>_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 %}
),
raw_charges as ({{ generate_stripe_sources_unioned_select("charges") }}),
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
stg_stripe__charges as (
select