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

needs to use {{this}} format for incremental #3341

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion models/solana_utils/solana_utils_daily_balances.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WITH
FROM {{ source('solana','account_activity') }}
WHERE tx_success
{% if is_incremental() %}
AND block_time >= date_trunc("day", now() - interval '1 day')
AND block_time > (SELECT max(day) FROM {{this}})
Copy link
Collaborator

@0xRobin 0xRobin May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably use >= here to not drop later incremental updates from the same day?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since day is derived from date_trunc(...), it represents the lower bound of the time, I think > will include all events in that date after UTC 00:00.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to update on same day, only next day. To prevent duplicates.

There is the edge case of missing an address if their balance changes later that day but not the next day.

But ignoring that case for now!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah @Hosuke you're right! I was confused but indeed because we compare block_time with the day timestamp this works and there's no real difference between > and >=. 👍

{% endif %}
)

Expand Down
6 changes: 6 additions & 0 deletions models/solana_utils/solana_utils_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ models:
tags: ['solana','balances']
description: >
get the daily balances for each address, from which we can materialize a latest balance later on.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- token_mint_address
- address
- day
columns:
- &day
name: day
Expand Down