Skip to content

fix(solana): align daily balances merge grain - #9829

Closed
0xRobin wants to merge 1 commit into
mainfrom
robin/CUR2-1524-solana-daily-balances
Closed

fix(solana): align daily balances merge grain#9829
0xRobin wants to merge 1 commit into
mainfrom
robin/CUR2-1524-solana-daily-balances

Conversation

@0xRobin

@0xRobin 0xRobin commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Fixes the incremental merge key for solana_utils.daily_balances so it matches the model's address/day output grain. Adds a dbt uniqueness test for that grain; existing duplicate rows will still require a full refresh/backfill of the table.

@cursor

cursor Bot commented Jun 25, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes merge behavior on a core incremental balances table; incorrect historical rows may persist until a full refresh, affecting downstream models like latest balances and staking joins.

Overview
Aligns solana_utils_daily_balances incremental merge grain with how rows are actually produced — one snapshot per address per day (the model already picks the latest activity with row_number() partitioned by address and day, not by token mint).

The merge unique_address_key surrogate changes from address + token_mint_address + day to address + day, so merges update the same logical daily row instead of treating different mints as separate keys. A dbt_utils.unique_combination_of_columns test on day and address documents and guards that grain.

Note: Historical duplicate rows from the old key may still need a full refresh/backfill before the new test passes. A small YAML fix restores the leader column description indentation on solana_utils_block_leaders.

Reviewed by Cursor Bugbot for commit ce678a0. Configure here.

@github-actions github-actions Bot added WIP work in progress dbt: solana covers the Solana dbt subproject labels Jun 25, 2026
@2bwfkjpr25-lab

Copy link
Copy Markdown

Thanks for addressing the incremental merge-grain mismatch!
This is only a contract clarification, not a request to expand this PR.
The current SQL produces one row per (address, day), and this PR aligns the merge key and uniqueness test with that implementation. However, the public Dune documentation describes each row as an end-of-day balance for a specific (address, token, day).
Could a maintainer confirm which grain is the intended public contract before this PR is finalized?

@2bwfkjpr25-lab

Copy link
Copy Markdown

Related follow-up: #9965 documents a separate state-semantics issue.

When the final balance-changing activity is lamport-only and its transaction metadata contains no token snapshot, coalesce(post_token_balance, 0) can store an unobserved token state as a known zero.

This is not a request to expand this PR. #9829 remains focused on aligning the incremental merge grain; historical duplicate rows still require the proposed full refresh/backfill.

@0xRobin 0xRobin closed this Sep 9, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dbt: solana covers the Solana dbt subproject WIP work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants