mirror of
https://github.com/FlipsideCrypto/solana-models.git
synced 2026-02-06 13:36:46 +00:00
deprecate silver__snapshot_stake_accounts (#659)
This commit is contained in:
parent
ba915cf20b
commit
8aacff420f
2
.github/workflows/dbt_run_daily.yml
vendored
2
.github/workflows/dbt_run_daily.yml
vendored
@ -48,7 +48,7 @@ jobs:
|
||||
dbt run-operation run_sp_snapshot_get_stake_accounts
|
||||
dbt run-operation run_sp_snapshot_get_vote_program_accounts
|
||||
dbt run -s models/bronze/bronze__validators_app_api.sql models/bronze/bronze__vote_accounts.sql models/bronze/bronze__stake_program_accounts.sql models/bronze/bronze__vote_accounts_extended_stats.sql
|
||||
dbt run -s models/silver/validator/silver__snapshot_stake_accounts.sql models/silver/validator/silver__snapshot_validators_app_data.sql models/silver/validator/silver__snapshot_vote_accounts.sql models/silver/validator/silver__snapshot_vote_accounts_extended_stats.sql
|
||||
dbt run -s models/silver/validator/silver__snapshot_validators_app_data.sql models/silver/validator/silver__snapshot_vote_accounts.sql models/silver/validator/silver__snapshot_vote_accounts_extended_stats.sql
|
||||
dbt run -s "solana_models,tag:nft_api"
|
||||
dbt run -s "solana_models,tag:daily"
|
||||
|
||||
|
||||
@ -1,85 +1,106 @@
|
||||
{{ config(
|
||||
{{
|
||||
config(
|
||||
materialized = 'incremental',
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'VALIDATOR' }}},
|
||||
meta = { 'database_tags': { 'table': { 'PURPOSE': 'VALIDATOR' }}},
|
||||
unique_key = ['fact_stake_accounts_id'],
|
||||
cluster_by = ['epoch','activation_epoch','deactivation_epoch'],
|
||||
cluster_by = ['epoch', 'activation_epoch', 'deactivation_epoch'],
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(stake_pubkey, vote_pubkey)'),
|
||||
post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(stake_pubkey, vote_pubkey)'),
|
||||
tags = ['scheduled_non_core']
|
||||
) }}
|
||||
)
|
||||
}}
|
||||
|
||||
{% set v1_cutoff_epoch = 669 %}
|
||||
|
||||
{% if execute %}
|
||||
{% if is_incremental() %}
|
||||
{% set query %}
|
||||
SELECT MAX(modified_timestamp) AS max_modified_timestamp
|
||||
FROM {{ this }}
|
||||
SELECT
|
||||
max(modified_timestamp) AS max_modified_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
{% endset %}
|
||||
|
||||
{% set max_modified_timestamp = run_query(query).columns[0].values()[0] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
SELECT
|
||||
epoch_recorded :: INT AS epoch,
|
||||
stake_pubkey,
|
||||
vote_pubkey,
|
||||
authorized_staker,
|
||||
authorized_withdrawer,
|
||||
lockup,
|
||||
rent_exempt_reserve,
|
||||
credits_observed,
|
||||
activation_epoch,
|
||||
deactivation_epoch,
|
||||
active_stake,
|
||||
warmup_cooldown_rate,
|
||||
type_stake,
|
||||
program,
|
||||
account_sol,
|
||||
rent_epoch,
|
||||
COALESCE (
|
||||
snapshot_stake_accounts_id,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['epoch', 'stake_pubkey']
|
||||
) }}
|
||||
) AS fact_stake_accounts_id,
|
||||
COALESCE(
|
||||
inserted_timestamp,
|
||||
'2000-01-01'
|
||||
) AS inserted_timestamp,
|
||||
COALESCE(
|
||||
modified_timestamp,
|
||||
'2000-01-01'
|
||||
) AS modified_timestamp
|
||||
epoch_recorded::INT AS epoch,
|
||||
stake_pubkey,
|
||||
vote_pubkey,
|
||||
authorized_staker,
|
||||
authorized_withdrawer,
|
||||
lockup,
|
||||
rent_exempt_reserve,
|
||||
credits_observed,
|
||||
activation_epoch,
|
||||
deactivation_epoch,
|
||||
active_stake,
|
||||
warmup_cooldown_rate,
|
||||
type_stake,
|
||||
program,
|
||||
account_sol,
|
||||
rent_epoch,
|
||||
snapshot_stake_accounts_2_id AS fact_stake_accounts_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__snapshot_stake_accounts') }}
|
||||
{% if is_incremental() %}
|
||||
{{ ref('silver__snapshot_stake_accounts_2') }}
|
||||
WHERE
|
||||
modified_timestamp >= '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
epoch > {{ v1_cutoff_epoch }}
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
epoch_recorded::INT AS epoch,
|
||||
stake_pubkey,
|
||||
vote_pubkey,
|
||||
authorized_staker,
|
||||
authorized_withdrawer,
|
||||
lockup,
|
||||
rent_exempt_reserve,
|
||||
credits_observed,
|
||||
activation_epoch,
|
||||
deactivation_epoch,
|
||||
active_stake,
|
||||
warmup_cooldown_rate,
|
||||
type_stake,
|
||||
program,
|
||||
account_sol,
|
||||
rent_epoch,
|
||||
coalesce(snapshot_stake_accounts_id, {{ dbt_utils.generate_surrogate_key(['epoch', 'stake_pubkey']) }}) AS fact_stake_accounts_id,
|
||||
coalesce(inserted_timestamp, '2000-01-01') AS inserted_timestamp,
|
||||
coalesce(modified_timestamp, '2000-01-01') AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__snapshot_stake_accounts') }}
|
||||
WHERE
|
||||
epoch <= {{ v1_cutoff_epoch }}
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= '{{ max_modified_timestamp }}'
|
||||
{% endif %}
|
||||
{% if not is_incremental() %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
epoch_ingested_at :: INT AS epoch,
|
||||
stake_pubkey,
|
||||
vote_pubkey,
|
||||
authorized_staker,
|
||||
authorized_withdrawer,
|
||||
lockup,
|
||||
rent_exempt_reserve,
|
||||
credits_observed,
|
||||
activation_epoch,
|
||||
deactivation_epoch,
|
||||
active_stake,
|
||||
warmup_cooldown_rate,
|
||||
type_stake,
|
||||
program,
|
||||
account_sol,
|
||||
rent_epoch,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['epoch', 'stake_pubkey']
|
||||
) }} AS fact_stake_accounts_id,
|
||||
'2000-01-01' as inserted_timestamp,
|
||||
'2000-01-01' AS modified_timestamp
|
||||
epoch_ingested_at::INT AS epoch,
|
||||
stake_pubkey,
|
||||
vote_pubkey,
|
||||
authorized_staker,
|
||||
authorized_withdrawer,
|
||||
lockup,
|
||||
rent_exempt_reserve,
|
||||
credits_observed,
|
||||
activation_epoch,
|
||||
deactivation_epoch,
|
||||
active_stake,
|
||||
warmup_cooldown_rate,
|
||||
type_stake,
|
||||
program,
|
||||
account_sol,
|
||||
rent_epoch,
|
||||
{{ dbt_utils.generate_surrogate_key(['epoch', 'stake_pubkey']) }} AS fact_stake_accounts_id,
|
||||
'2000-01-01' AS inserted_timestamp,
|
||||
'2000-01-01' AS modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__historical_stake_account') }}
|
||||
{{ ref('silver__historical_stake_account') }}
|
||||
{% endif %}
|
||||
|
||||
@ -8,7 +8,7 @@ models:
|
||||
tests:
|
||||
- reference_tx_missing:
|
||||
reference_tables:
|
||||
- 'silver__snapshot_stake_accounts'
|
||||
- 'silver__snapshot_stake_accounts_2'
|
||||
id_column: 'stake_pubkey'
|
||||
columns:
|
||||
- name: epoch
|
||||
|
||||
Loading…
Reference in New Issue
Block a user