Create macro and use it in balance transactions
This commit is contained in:
parent
1cdab6634e
commit
306e2ad970
2 changed files with 16 additions and 14 deletions
15
macros/generate_stripe_sources_unioned_select.sql
Normal file
15
macros/generate_stripe_sources_unioned_select.sql
Normal 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 %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue