Skip to content

Commit

Permalink
ERC20 merge key (#1248)
Browse files Browse the repository at this point in the history
* merge key
  • Loading branch information
dot2dotseurat authored Jul 5, 2022
1 parent 4b7c098 commit ee32cbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 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_day'
)
}}

Expand All @@ -13,14 +13,18 @@ select
tr.wallet_address,
tr.token_address,
t.symbol,
tr.wallet_address || '-' || tr.token_address || '-' || date_trunc('day', tr.evt_block_time) as wallet_contract_day,
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('day', tr.evt_block_time) > now() - interval 2 days
{% endif %}
group by
date_trunc('day', tr.evt_block_time), tr.wallet_address, tr.token_address, t.symbol,unique_tx_id
date_trunc('day', tr.evt_block_time),
tr.wallet_address,
tr.token_address,
t.symbol,
tr.wallet_address || '-' || tr.token_address || '-' || date_trunc('day', tr.evt_block_time)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ models:
contibutors: soispoke, dot2dotseurat
config:
tags: ['transfers', 'ethereum', 'erc20', 'soispoke', 'dot2dotseurat']
description: "ERC20 Token Transfers on Ethereum. This table is updated every 15 minutes."
description: "ERC20 Token Transfers on Ethereum. This table is updated every 30 minutes."
columns:
- name: unique_transfer_id
description: "Unique transfer ID (used for testing for duplicates)"
Expand Down Expand Up @@ -135,7 +135,7 @@ models:
contibutors: soispoke, dot2dotseurat, hildobby
config:
tags: ['transfers', 'ethereum', 'erc721', 'soispoke', 'dot2dotseurat', 'hildobby']
description: "ERC721 Token Transfers on Ethereum. This table is updated every 15 minutes."
description: "ERC721 Token Transfers on Ethereum. This table is updated every 30 minutes."
columns:
- name: unique_tx_id
description: "Unique tx ID (testing)"
Expand Down Expand Up @@ -230,7 +230,7 @@ models:
contibutors: soispoke
config:
tags: ['transfers', 'ethereum', 'erc1155', 'soispoke']
description: "ERC1155 Token Transfers on Ethereum. This table is updated every 15 minutes."
description: "ERC1155 Token Transfers on Ethereum. This table is updated every 30 minutes."
columns:
- name: unique_tx_id
description: "Unique tx ID (testing)"
Expand Down

0 comments on commit ee32cbb

Please sign in to comment.