From 554dec30eb41fdf7688dc841375c6b285ffa8d9b Mon Sep 17 00:00:00 2001 From: Alan Ghobadi Date: Sat, 6 Jul 2024 16:09:00 +0200 Subject: [PATCH] Make latest balances incremental --- .../solana_utils/solana_utils_latest_balances.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/solana/models/solana_utils/solana_utils_latest_balances.sql b/solana/models/solana_utils/solana_utils_latest_balances.sql index 5f7f5a51867..4bb3ebd7862 100644 --- a/solana/models/solana_utils/solana_utils_latest_balances.sql +++ b/solana/models/solana_utils/solana_utils_latest_balances.sql @@ -2,8 +2,11 @@ config( schema = 'solana_utils', alias = 'latest_balances', - materialized='table', - + materialized='incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], + unique_key = ['address', 'token_mint_address', 'token_balance_owner'] post_hook='{{ expose_spells(\'["solana"]\', "sector", "solana_utils", @@ -21,6 +24,10 @@ WITH , token_balance_owner , row_number() OVER (partition by address order by day desc) as latest_balance FROM {{ ref('solana_utils_daily_balances') }} + {% if is_incremental() %} + WHERE {{incremental_predicate('day')}} + {% endif %} + ) SELECT