Skip to content

Commit

Permalink
Make latest balances incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
aalan3 committed Jul 6, 2024
1 parent 163d1a9 commit 60090a4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions solana/models/solana_utils/solana_utils_latest_balances.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
config(
schema = 'solana_utils',
alias = 'latest_balances',
materialized='table',

materialized='incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['address'],
post_hook='{{ expose_spells(\'["solana"]\',
"sector",
"solana_utils",
Expand All @@ -21,6 +23,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
Expand All @@ -32,4 +38,4 @@ SELECT
, now() as updated_at
FROM updated_balances ub
LEFT JOIN {{ ref('solana_utils_token_accounts')}} tk ON tk.address = ub.address
WHERE latest_balance = 1
WHERE latest_balance = 1

0 comments on commit 60090a4

Please sign in to comment.