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

Make latest balances incremental #6337

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
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
Loading