Skip to content

Commit

Permalink
Celo: adding traces (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Dec 12, 2024
1 parent 79e6e73 commit 743120f
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
33 changes: 33 additions & 0 deletions models/projects/celo/raw/ez_celo_traces.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{
config(
materialized="view",
snowflake_warehouse="CELO",
database="celo",
schema="raw",
alias="ez_traces",
)
}}

select
block_number
, block_timestamp
, block_hash
, transaction_hash
, transaction_index
, from_address
, to_address
, value
, input
, output
, trace_type
, call_type
, reward_type
, gas
, gas_used
, subtraces
, trace_address
, error
, status
, trace_id
, id
from {{ref("fact_celo_traces")}}
1 change: 1 addition & 0 deletions models/staging/celo/__celo__sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sources:
tables:
- name: raw_celo_blocks_receipts
- name: raw_celo_epoch_rewards
- name: raw_celo_traces_parquet
- name: BALANCES
schema: PROD
database: PC_DBT_DB
Expand Down
8 changes: 7 additions & 1 deletion models/staging/celo/fact_celo_token_transfers.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{{ config(materialized="incremental", unique_key=["transaction_hash", "event_index"]) }}
{{
config(
materialized="incremental",
unique_key=["transaction_hash", "event_index"],
snowflake_warehouse="CELO_MD"
)
}}
with
prices as ({{get_multiple_coingecko_price_with_latest('celo')}})
, celo_token_transfers as ({{ token_transfer_events("celo") }})
Expand Down
54 changes: 54 additions & 0 deletions models/staging/celo/fact_celo_traces.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ config(materialized="incremental", unique_key="id") }}
with
raw_traces as (
select
parquet_raw:block_number as block_number
, parquet_raw:block_timestamp::timestamp as block_timestamp
, parquet_raw:block_hash as block_hash
, parquet_raw:transaction_hash as transaction_hash
, parquet_raw:transaction_index as transaction_index
, parquet_raw:from_address as from_address
, parquet_raw:to_address as to_address
, parquet_raw:value as value
, parquet_raw:input as input
, parquet_raw:output as output
, parquet_raw:trace_type as trace_type
, parquet_raw:call_type as call_type
, parquet_raw:reward_type as reward_type
, parquet_raw:gas as gas
, parquet_raw:gas_used as gas_used
, parquet_raw:subtraces as subtraces
, parquet_raw:trace_address as trace_address
, parquet_raw:error as error
, parquet_raw:status as status
, parquet_raw:trace_id as trace_id
, parquet_raw:id as id
from {{ source("PROD_LANDING", "raw_celo_traces_parquet") }}
{% if is_incremental() %}
where block_timestamp::timestamp >= (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
{% endif %}
)
select
block_number
, block_timestamp
, block_hash
, transaction_hash
, transaction_index
, from_address
, to_address
, value
, input
, output
, trace_type
, call_type
, reward_type
, gas
, gas_used
, subtraces
, trace_address
, error
, status
, trace_id
, id
from raw_receipt_transactions
qualify row_number() over (partition by id order by block_timestamp desc) = 1

0 comments on commit 743120f

Please sign in to comment.