Skip to content

Commit

Permalink
wallet contract hour merge key (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
dot2dotseurat authored Jul 6, 2022
1 parent ee32cbb commit a0e23e4
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
materialized ='incremental',
file_format ='delta',
incremental_strategy='merge',
unique_key='unique_transfer_id'
unique_key='wallet_contract_hour'
)
}}

Expand All @@ -13,14 +13,18 @@ select
tr.wallet_address,
tr.token_address,
t.symbol,
tr.wallet_address || '-' || tr.token_address || '-' || date_trunc('hour', tr.evt_block_time) as wallet_contract_hour,
sum(tr.amount_raw) as amount_raw,
sum(tr.amount_raw / power(10, t.decimals)) as amount,
unique_tx_id || '-' || wallet_address || '-' || token_address || '-' || sum(tr.amount_raw)::string as unique_transfer_id
sum(tr.amount_raw / power(10, t.decimals)) as amount
from {{ ref('transfers_ethereum_erc20') }} tr
left join {{ ref('tokens_ethereum_erc20') }} t on t.contract_address = tr.token_address
{% if is_incremental() %}
-- this filter will only be applied on an incremental run
where date_trunc('hour', tr.evt_block_time) > now() - interval 2 days
{% endif %}
group by
date_trunc('hour', tr.evt_block_time), tr.wallet_address, tr.token_address, t.symbol,unique_tx_id
date_trunc('hour', tr.evt_block_time),
tr.wallet_address,
tr.token_address,
t.symbol,
tr.wallet_address || '-' || tr.token_address || '-' || date_trunc('hour', tr.evt_block_time)

0 comments on commit a0e23e4

Please sign in to comment.