From 6db70d7bb9cf936d571f9315232064cc25f0fa25 Mon Sep 17 00:00:00 2001 From: Son Do <34179343+Sunny77D@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:50:50 -0500 Subject: [PATCH] Son/drift update (#677) --- models/staging/drift/fact_drift_amm_revenue.sql | 2 ++ models/staging/drift/fact_drift_daily_perp_data.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/models/staging/drift/fact_drift_amm_revenue.sql b/models/staging/drift/fact_drift_amm_revenue.sql index b6c235ff..8f7c4aaa 100644 --- a/models/staging/drift/fact_drift_amm_revenue.sql +++ b/models/staging/drift/fact_drift_amm_revenue.sql @@ -3,6 +3,7 @@ WITH fact_drift_daily_perp_data AS ( SELECT date + , max(latest_timestamp) as latest_timestamp , sum(latest_excess_pnl) as latest_excess_pnl FROM {{ref('fact_drift_daily_perp_data')}} @@ -10,6 +11,7 @@ WITH fact_drift_daily_perp_data AS ( ) SELECT date + , latest_timestamp , latest_excess_pnl - LAG(latest_excess_pnl) OVER (ORDER BY date) as total_revenue , latest_excess_pnl FROM diff --git a/models/staging/drift/fact_drift_daily_perp_data.sql b/models/staging/drift/fact_drift_daily_perp_data.sql index 647c904c..797b4f7a 100644 --- a/models/staging/drift/fact_drift_daily_perp_data.sql +++ b/models/staging/drift/fact_drift_daily_perp_data.sql @@ -11,6 +11,7 @@ SELECT AVG(value:oi_net::float) as daily_avg_net_open_interest, AVG(value:net_user_pnl::float) as daily_avg_net_user_pnl, MAX_BY(value:excess_pnl::float, TO_TIMESTAMP(value:timestamp::string, 'YYYY/MM/DD HH24:MI:SS')) as latest_excess_pnl, + MAX(TO_TIMESTAMP(value:timestamp::string, 'YYYY/MM/DD HH24:MI:SS')) as latest_timestamp, AVG(value:est_funding_dollars::float) as daily_avg_est_funding_dollars FROM {{ source("PROD_LANDING", "raw_drift_perp_market_data") }} , lateral flatten(input => parse_json(source_json))