diff --git a/spellbook/models/transfers/ethereum/erc20/transfers_ethereum_erc20_agg_hour.sql b/spellbook/models/transfers/ethereum/erc20/transfers_ethereum_erc20_agg_hour.sql index 9f82fbed790..a17b1380879 100644 --- a/spellbook/models/transfers/ethereum/erc20/transfers_ethereum_erc20_agg_hour.sql +++ b/spellbook/models/transfers/ethereum/erc20/transfers_ethereum_erc20_agg_hour.sql @@ -3,7 +3,7 @@ materialized ='incremental', file_format ='delta', incremental_strategy='merge', - unique_key='unique_transfer_id' + unique_key='wallet_contract_hour' ) }} @@ -13,9 +13,9 @@ 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() %} @@ -23,4 +23,8 @@ left join {{ ref('tokens_ethereum_erc20') }} t on t.contract_address = tr.token_ 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)