Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flow's daa SQL #535

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions models/staging/flow/fact_flow_daa_txns.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
{{ config(materialized="view") }}
select
date_trunc('day', block_timestamp) as date,
count(distinct authorizers) as daa,
count(distinct tx_id) as txns,
'flow' as chain
from flow_flipside.core.fact_transactions
where tx_succeeded = 'TRUE'
group by date

WITH ez_actors_data AS (
SELECT
date_trunc('day', b.block_timestamp) AS date,
COUNT(DISTINCT CAST(value AS VARCHAR)) AS daa, -- Explicitly casting to VARCHAR
COUNT(DISTINCT b.tx_id) AS txns,
FROM
flow_flipside.core.ez_transaction_actors AS b,
LATERAL FLATTEN(INPUT => b.actors) AS a -- Flattening the actors array
GROUP BY date
), evm_data AS (
SELECT
date_trunc('day', block_timestamp) AS date,
COUNT(DISTINCT from_address) AS daa,
COUNT(DISTINCT tx_hash) AS txns
FROM flow_flipside.core_evm.fact_transactions
GROUP BY date
)
SELECT
date,
SUM(daa) AS daa,
SUM(txns) AS txns,
'flow' AS chain
FROM (
SELECT * FROM ez_actors_data
UNION ALL
SELECT * FROM evm_data
) AS combined_data
GROUP BY date
Loading