From b7db3d0fb3fe8a566c1780fa1983ef4cc1a5de65 Mon Sep 17 00:00:00 2001 From: Son Do Date: Thu, 15 Aug 2024 14:52:40 -0400 Subject: [PATCH] Converted Aptos data to incremental --- .../fact_aptos_daa_txns_gas_gas_usd_revenue.sql | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/models/staging/aptos/fact_aptos_daa_txns_gas_gas_usd_revenue.sql b/models/staging/aptos/fact_aptos_daa_txns_gas_gas_usd_revenue.sql index cc1ce302..66db9f85 100644 --- a/models/staging/aptos/fact_aptos_daa_txns_gas_gas_usd_revenue.sql +++ b/models/staging/aptos/fact_aptos_daa_txns_gas_gas_usd_revenue.sql @@ -1,4 +1,4 @@ -{{ config(materialized="table") }} +{{ config(materialized="incremental", unique_key='date') }} with apt_prices as ({{ get_coingecko_price_with_latest("aptos") }}), single_signed_transactions as ( @@ -8,6 +8,9 @@ with tx_type = 'user_transaction' and success = 'true' and parse_json(signature):public_key is not null + {% if is_incremental() %} + and block_timestamp::date > (select dateadd('day', -3, max(date)) from {{ this }}) + {% endif %} ), primary_multi_signed_transactions as ( select @@ -18,6 +21,9 @@ with tx_type = 'user_transaction' and success = 'true' and parse_json(signature):sender is not null + {% if is_incremental() %} + and block_timestamp::date > (select dateadd('day', -3, max(date)) from {{ this }}) + {% endif %} ), raw_secondary_multi_signed_transactions as ( select @@ -28,6 +34,9 @@ with tx_type = 'user_transaction' and success = 'true' and parse_json(signature):secondary_signers is not null + {% if is_incremental() %} + and block_timestamp::date > (select dateadd('day', -3, max(date)) from {{ this }}) + {% endif %} ), secondary_multi_signed_transactions as ( select block_timestamp::date as date, value:"public_key" as signer @@ -69,6 +78,9 @@ with sum(gas_used * gas_unit_price) / 1E8 as gas from aptos_flipside.core.fact_transactions where tx_type = 'user_transaction' + {% if is_incremental() %} + and block_timestamp::date > (select dateadd('day', -3, max(date)) from {{ this }}) + {% endif %} group by block_timestamp::date ), raw as (