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 %}
|
||||
|
|
@ -1,19 +1,6 @@
|
|||
with
|
||||
raw_balance_transactions 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, "balance_transactions") }}
|
||||
{% if not loop.last -%}
|
||||
union all
|
||||
{%- endif %}
|
||||
{% endfor %}
|
||||
{{ generate_stripe_sources_unioned_select("balance_transactions") }}
|
||||
),
|
||||
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
|
||||
stg_stripe__balance_transactions as (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue