Skip to content

Commit

Permalink
C911: Polygon ZK (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebMelendez01 authored Nov 19, 2024
1 parent 646dfff commit 21f944e
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions models/staging/polygon_zk/fact_polygon_zk_daa_txns_gas_usd.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,28 @@ with
select parse_json(source_json) as data
from {{ source("PROD_LANDING", "raw_polygon_zk_data") }}
where extraction_date = (select max_date from max_extraction)
),
prices as ({{ get_coingecko_price_with_latest('ethereum') }})
, extracted_data as (
select
date(left(value:"date_time"::string, 10)) as date,
value:unique_active_users as daa,
value:all_transactions as txns,
value:txn_fees::double as gas,
value as source,
'polygon_zk' as chain
from polygon_zk_data,
lateral flatten(input => data:"data":"records")
where date < to_date(sysdate())
)
select
date(left(value:"date_time"::string, 10)) as date,
value:unique_active_users as daa,
value:all_transactions as txns,
value:txn_fees_usd::double as gas_usd,
value as source,
select
extracted_data.date,
daa,
txns,
gas,
gas * price as gas_usd,
'polygon_zk' as chain
from polygon_zk_data, lateral flatten(input => data:"data":"records")
where date < to_date(sysdate())
from extracted_data
left join prices using(date)


0 comments on commit 21f944e

Please sign in to comment.