Skip to content

Commit

Permalink
fix duplicated unique key (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-dude authored Aug 27, 2022
1 parent fb85c70 commit f19611b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions models/safe/ethereum/safe_ethereum_eth_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
materialized='incremental',
alias='eth_transfers',
partition_by = ['block_date'],
unique_key = ['block_date', 'tx_hash', 'trace_address'],
unique_key = ['block_date', 'tx_hash', 'trace_address', 'amount_raw'],
on_schema_change='fail',
file_format ='delta',
incremental_strategy='merge'
Expand All @@ -20,8 +20,9 @@ select
from {{ source('ethereum', 'traces') }} et
join {{ ref('safe_ethereum_safes') }} s on et.from = s.address
and et.from != et.to -- exclude calls to self to guarantee unique key property
and success = true
and (lower(call_type) not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)
and et.success = true
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null)
and et.value > 0 -- exclue 0 value traces
where et.block_time > '2018-11-24' -- for initial query optimisation
{% if is_incremental() %}
-- to prevent potential counterfactual safe deployment issues we take a bigger interval
Expand All @@ -40,8 +41,9 @@ select
from {{ source('ethereum', 'traces') }} et
join {{ ref('safe_ethereum_safes') }} s on et.to = s.address
and et.from != et.to -- exclude calls to self to guarantee unique key property
and success = true
and (lower(call_type) not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)
and et.success = true
and (lower(et.call_type) not in ('delegatecall', 'callcode', 'staticcall') or et.call_type is null)
and et.value > 0 -- exclue 0 value traces
where et.block_time > '2018-11-24' -- for initial query optimisation
{% if is_incremental() %}
-- to prevent potential counterfactual safe deployment issues we take a bigger interval
Expand Down

0 comments on commit f19611b

Please sign in to comment.