Create macro and use it in balance transactions

This commit is contained in:
Pablo Martin 2024-03-05 13:33:13 +01:00
parent 1cdab6634e
commit 306e2ad970
2 changed files with 16 additions and 14 deletions

View file

@ -0,0 +1,15 @@
/*
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"
*/
{% macro generate_stripe_sources_unioned_select(source_table) -%}
{% set countries = ["us", "uk"] %}
{% for country in countries %}
select *, 'stripe_{{ country }}_account' as stripe_source_account
from {{ source("stripe_" ~ country, source_table) }}
{% if not loop.last -%}
union all
{%- endif %}
{% endfor %}
{%- endmacro %}