improve stg_stripe__balance_transactions
This commit is contained in:
parent
d262aff8c2
commit
9c423e3f3c
1 changed files with 19 additions and 6 deletions
|
|
@ -2,27 +2,40 @@ with
|
|||
raw_balance_transactions as (
|
||||
select * from {{ source("stripe_uk", "balance_transactions") }}
|
||||
),
|
||||
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
|
||||
stg_stripe__balance_transactions as (
|
||||
select
|
||||
{{ adapter.quote("id") }},
|
||||
{{ adapter.quote("fee") }},
|
||||
{{ adapter.quote("net") }},
|
||||
{{ adapter.quote("fee") }} / (10 ^ cur.decimal_positions) as fee,
|
||||
{{ adapter.quote("net") }} / (10 ^ cur.decimal_positions) as net,
|
||||
{{ adapter.quote("type") }},
|
||||
{{ adapter.quote("amount") }},
|
||||
{{ adapter.quote("amount") }} / (10 ^ cur.decimal_positions) as amount,
|
||||
{{ adapter.quote("object") }},
|
||||
{{ adapter.quote("source") }},
|
||||
{{ adapter.quote("status") }},
|
||||
to_timestamp({{ adapter.quote("created") }}) as created_at_utc,
|
||||
{{ adapter.quote("currency") }},
|
||||
cast(
|
||||
to_timestamp({{ adapter.quote("created") }}) as date
|
||||
) as created_date_utc,
|
||||
upper({{ adapter.quote("currency") }}) as currency,
|
||||
{{ adapter.quote("description") }},
|
||||
{{ adapter.quote("fee_details") }},
|
||||
to_timestamp({{ adapter.quote("available_on") }}) as available_at_utc,
|
||||
cast(
|
||||
to_timestamp({{ adapter.quote("available_on") }}) as date
|
||||
) as available_date_utc,
|
||||
{{ adapter.quote("exchange_rate") }},
|
||||
{{ adapter.quote("sourced_transfers") }},
|
||||
{{ adapter.quote("reporting_category") }},
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_date
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc,
|
||||
cast(
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as date
|
||||
) as dwh_extracted_date_utc
|
||||
|
||||
from raw_balance_transactions
|
||||
from raw_balance_transactions bt
|
||||
left join
|
||||
stg_seed__currencies cur
|
||||
on upper(bt.{{ adapter.quote("currency") }}) = cur.iso_4217_code
|
||||
)
|
||||
select *
|
||||
from stg_stripe__balance_transactions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue