From 40716e13255d45b2edde53921f805bad8a04b6d5 Mon Sep 17 00:00:00 2001 From: desmond-hui <97470747+desmond-hui@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:20:57 -0800 Subject: [PATCH] replace v1 staking lp actions with v2, add inner_index to gold (#806) --- .../gold/gov/gov__ez_staking_lp_actions.sql | 31 ++++++++++--------- .../gold/gov/gov__ez_staking_lp_actions.yml | 6 +++- .../gold/gov/gov__fact_staking_lp_actions.sql | 27 ++++++++-------- .../gold/gov/gov__fact_staking_lp_actions.yml | 6 +++- .../non_core/silver__staking_lp_actions.sql | 3 +- .../silver__staking_lp_actions_labeled.sql | 4 ++- 6 files changed, 45 insertions(+), 32 deletions(-) diff --git a/models/gold/gov/gov__ez_staking_lp_actions.sql b/models/gold/gov/gov__ez_staking_lp_actions.sql index 7c31692a..b80a32b2 100644 --- a/models/gold/gov/gov__ez_staking_lp_actions.sql +++ b/models/gold/gov/gov__ez_staking_lp_actions.sql @@ -1,7 +1,13 @@ {{ config( materialized = 'view', - meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }}}, - tags = ["scheduled_non_core"], + meta = { + 'database_tags': { + 'table': { + 'PURPOSE': 'STAKING' + } + } + }, + tags = ['scheduled_non_core'] ) }} SELECT @@ -9,7 +15,8 @@ SELECT block_timestamp, tx_id, succeeded, - INDEX, + index, + inner_index, event_type, signers, stake_authority, @@ -25,19 +32,13 @@ SELECT validator_rank, commission, validator_name, - COALESCE ( - staking_lp_actions_labeled_id, + coalesce( + staking_lp_actions_labeled_2_id, {{ dbt_utils.generate_surrogate_key( - ['block_id','tx_id','index'] + ['block_id', 'tx_id', 'index'] ) }} ) AS ez_staking_lp_actions_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp + coalesce(inserted_timestamp, '2000-01-01') AS inserted_timestamp, + coalesce(modified_timestamp, '2000-01-01') AS modified_timestamp FROM - {{ ref('silver__staking_lp_actions_labeled') }} \ No newline at end of file + {{ ref('silver__staking_lp_actions_labeled_2') }} \ No newline at end of file diff --git a/models/gold/gov/gov__ez_staking_lp_actions.yml b/models/gold/gov/gov__ez_staking_lp_actions.yml index a9a657db..bf83e403 100644 --- a/models/gold/gov/gov__ez_staking_lp_actions.yml +++ b/models/gold/gov/gov__ez_staking_lp_actions.yml @@ -16,7 +16,11 @@ models: tests: - dbt_expectations.expect_column_to_exist - name: INDEX - description: Location of the event within the instructions of a transaction + description: "{{ doc('index') }}" + tests: + - dbt_expectations.expect_column_to_exist + - name: INNER_INDEX + description: "{{ doc('inner_index') }}" tests: - dbt_expectations.expect_column_to_exist - name: SUCCEEDED diff --git a/models/gold/gov/gov__fact_staking_lp_actions.sql b/models/gold/gov/gov__fact_staking_lp_actions.sql index 45be0b38..a836ba14 100644 --- a/models/gold/gov/gov__fact_staking_lp_actions.sql +++ b/models/gold/gov/gov__fact_staking_lp_actions.sql @@ -1,6 +1,12 @@ {{ config( materialized = 'view', - meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }}}, + meta = { + 'database_tags': { + 'table': { + 'PURPOSE': 'STAKING' + } + } + }, tags = ['scheduled_non_core'] ) }} @@ -10,6 +16,7 @@ SELECT tx_id, succeeded, index, + inner_index, event_type, program_id, signers, @@ -20,19 +27,13 @@ SELECT post_balances, pre_token_balances, post_token_balances, - COALESCE ( - staking_lp_actions_id, + coalesce( + staking_lp_actions_2_id, {{ dbt_utils.generate_surrogate_key( - ['block_id', 'tx_id', 'index'] + ['block_id', 'tx_id', 'index', 'inner_index'] ) }} ) AS fact_staking_lp_actions_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp + coalesce(inserted_timestamp,'2000-01-01') AS inserted_timestamp, + coalesce(modified_timestamp, '2000-01-01') AS modified_timestamp FROM - {{ ref('silver__staking_lp_actions') }} + {{ ref('silver__staking_lp_actions_2') }} diff --git a/models/gold/gov/gov__fact_staking_lp_actions.yml b/models/gold/gov/gov__fact_staking_lp_actions.yml index 2542b5c3..7818c7a2 100644 --- a/models/gold/gov/gov__fact_staking_lp_actions.yml +++ b/models/gold/gov/gov__fact_staking_lp_actions.yml @@ -16,7 +16,11 @@ models: tests: - dbt_expectations.expect_column_to_exist - name: INDEX - description: Location of the event within the instructions of a transaction + description: "{{ doc('index') }}" + tests: + - dbt_expectations.expect_column_to_exist + - name: INNER_INDEX + description: "{{ doc('inner_index') }}" tests: - dbt_expectations.expect_column_to_exist - name: SUCCEEDED diff --git a/models/silver/non_core/silver__staking_lp_actions.sql b/models/silver/non_core/silver__staking_lp_actions.sql index e3e42759..202c2f14 100644 --- a/models/silver/non_core/silver__staking_lp_actions.sql +++ b/models/silver/non_core/silver__staking_lp_actions.sql @@ -5,7 +5,8 @@ cluster_by = ['block_timestamp::DATE','event_type'], full_refresh = false, post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(tx_id)'), - tags = ['scheduled_non_core'] + tags = ['deprecated'], + enabled = false, ) }} WITH base_e AS ( diff --git a/models/silver/non_core/silver__staking_lp_actions_labeled.sql b/models/silver/non_core/silver__staking_lp_actions_labeled.sql index e7f56444..15c8792a 100644 --- a/models/silver/non_core/silver__staking_lp_actions_labeled.sql +++ b/models/silver/non_core/silver__staking_lp_actions_labeled.sql @@ -4,7 +4,9 @@ incremental_strategy = 'delete+insert', cluster_by = ['block_timestamp::DATE','event_type'], post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(tx_id,stake_authority,withdraw_authority,stake_account)'), - tags = ['scheduled_non_core'] + tags = ['deprecated'], + enabled = false, + full_refresh = false, ) }} WITH base_staking_lp_actions AS (