diff --git a/models/gold/defi/defi__fact_stake_pool_actions.sql b/models/gold/defi/defi__fact_stake_pool_actions.sql index 34cffcda5..ba110abbb 100644 --- a/models/gold/defi/defi__fact_stake_pool_actions.sql +++ b/models/gold/defi/defi__fact_stake_pool_actions.sql @@ -1,6 +1,11 @@ {{ config( - materialized = 'view', - meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }} }, + materialized = 'incremental', + meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }}}, + unique_key = ['fact_stake_pool_actions_id'], + incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"], + cluster_by = ['block_timestamp::DATE','modified_timestamp::DATE', 'action', 'stake_pool'], + merge_exclude_columns = ["inserted_timestamp"], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id, address)'), tags = ['scheduled_non_core'] ) }} @@ -34,6 +39,14 @@ FROM {{ ref( 'silver__stake_pool_actions_lido' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} UNION ALL SELECT 'socean' AS stake_pool_name, @@ -54,6 +67,14 @@ FROM {{ ref( 'silver__stake_pool_actions_socean_view' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} UNION ALL SELECT 'eversol' AS stake_pool_name, @@ -76,6 +97,14 @@ FROM {{ ref( 'silver__stake_pool_actions_eversol_view' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} UNION ALL SELECT CASE @@ -113,6 +142,14 @@ FROM {{ ref( 'silver__stake_pool_actions_generic' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} UNION ALL SELECT 'marinade' AS stake_pool_name, @@ -144,6 +181,14 @@ FROM {{ ref( 'silver__stake_pool_actions_marinade' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} UNION ALL SELECT 'jito' AS stake_pool_name, @@ -164,3 +209,11 @@ FROM {{ ref( 'silver__stake_pool_actions_jito' ) }} +{% if is_incremental() %} +WHERE modified_timestamp >= ( + SELECT + MAX(modified_timestamp) + FROM + {{ this }} +) +{% endif %} diff --git a/models/silver/bridges/silver__bridge_debridge_transfers.sql b/models/silver/bridges/silver__bridge_debridge_transfers.sql index 78f0c4dac..1d32b257a 100644 --- a/models/silver/bridges/silver__bridge_debridge_transfers.sql +++ b/models/silver/bridges/silver__bridge_debridge_transfers.sql @@ -3,6 +3,8 @@ unique_key = ["block_id","tx_id","index"], incremental_predicates = ['DBT_INTERNAL_DEST.block_timestamp::date >= LEAST(current_date-7,(select min(block_timestamp)::date from ' ~ generate_tmp_view_name(this) ~ '))'], cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id,user_address,mint)'), + tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/bridges/silver__bridge_mayan_transfers.sql b/models/silver/bridges/silver__bridge_mayan_transfers.sql index 54361933d..612923fbc 100644 --- a/models/silver/bridges/silver__bridge_mayan_transfers.sql +++ b/models/silver/bridges/silver__bridge_mayan_transfers.sql @@ -3,6 +3,7 @@ unique_key = ["block_id","tx_id","index"], incremental_predicates = ['DBT_INTERNAL_DEST.block_timestamp::date >= LEAST(current_date-7,(select min(block_timestamp)::date from ' ~ generate_tmp_view_name(this) ~ '))'], cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id,user_address,mint)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/bridges/silver__bridge_wormhole_transfers.sql b/models/silver/bridges/silver__bridge_wormhole_transfers.sql index 5cf590108..dd9f42eaf 100644 --- a/models/silver/bridges/silver__bridge_wormhole_transfers.sql +++ b/models/silver/bridges/silver__bridge_wormhole_transfers.sql @@ -3,6 +3,7 @@ unique_key = ["block_id","tx_id","index","direction"], incremental_predicates = ['DBT_INTERNAL_DEST.block_timestamp::date >= LEAST(current_date-7,(select min(block_timestamp)::date from ' ~ generate_tmp_view_name(this) ~ '))'], cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id,user_address,mint)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/prices/silver__complete_native_prices.sql b/models/silver/prices/silver__complete_native_prices.sql index a88ed8dca..5df4e9beb 100644 --- a/models/silver/prices/silver__complete_native_prices.sql +++ b/models/silver/prices/silver__complete_native_prices.sql @@ -2,6 +2,7 @@ materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_native_prices_id', + cluster_by = ['HOUR::DATE'], tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/prices/silver__complete_provider_asset_metadata.sql b/models/silver/prices/silver__complete_provider_asset_metadata.sql index b9132ede5..48b0cfc43 100644 --- a/models/silver/prices/silver__complete_provider_asset_metadata.sql +++ b/models/silver/prices/silver__complete_provider_asset_metadata.sql @@ -2,6 +2,7 @@ materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_provider_asset_metadata_id', + post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(asset_id,token_address,name,symbol)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/prices/silver__complete_provider_prices.sql b/models/silver/prices/silver__complete_provider_prices.sql index 0fd657631..4407b616a 100644 --- a/models/silver/prices/silver__complete_provider_prices.sql +++ b/models/silver/prices/silver__complete_provider_prices.sql @@ -2,6 +2,8 @@ materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_provider_prices_id', + cluster_by = ['HOUR::DATE'], + post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(asset_id)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/prices/silver__complete_token_asset_metadata.sql b/models/silver/prices/silver__complete_token_asset_metadata.sql index 228ea496c..baf502d85 100644 --- a/models/silver/prices/silver__complete_token_asset_metadata.sql +++ b/models/silver/prices/silver__complete_token_asset_metadata.sql @@ -2,6 +2,7 @@ materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_token_asset_metadata_id', + post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(asset_id,token_address,name,symbol)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/prices/silver__complete_token_prices.sql b/models/silver/prices/silver__complete_token_prices.sql index 032d1c26c..bcdbc7278 100644 --- a/models/silver/prices/silver__complete_token_prices.sql +++ b/models/silver/prices/silver__complete_token_prices.sql @@ -2,6 +2,8 @@ materialized = 'incremental', incremental_strategy = 'delete+insert', unique_key = 'complete_token_prices_id', + cluster_by = ['HOUR::DATE'], + post_hook = enable_search_optimization('{{this.schema}}', '{{this.identifier}}', 'ON EQUALITY(token_address,symbol)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/silver__blocks.sql b/models/silver/silver__blocks.sql index b0b8a87a8..5f7a87d51 100644 --- a/models/silver/silver__blocks.sql +++ b/models/silver/silver__blocks.sql @@ -4,6 +4,7 @@ incremental_strategy = 'delete+insert', cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date'], tags = ['scheduled_core'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(block_id)'), full_refresh = false ) }} diff --git a/models/silver/tokens/silver__token_burn_actions.sql b/models/silver/tokens/silver__token_burn_actions.sql index 2efc2aa8c..1fc818ab6 100644 --- a/models/silver/tokens/silver__token_burn_actions.sql +++ b/models/silver/tokens/silver__token_burn_actions.sql @@ -3,6 +3,7 @@ unique_key = "CONCAT_WS('-', tx_id, index, inner_index, mint)", incremental_strategy = 'delete+insert', cluster_by = ['block_timestamp::DATE'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id,mint,burn_authority,token_account)'), tags = ['scheduled_non_core'] ) }} diff --git a/models/silver/tokens/silver__token_mint_actions.sql b/models/silver/tokens/silver__token_mint_actions.sql index b39313084..5989d8101 100644 --- a/models/silver/tokens/silver__token_mint_actions.sql +++ b/models/silver/tokens/silver__token_mint_actions.sql @@ -4,6 +4,7 @@ incremental_strategy = 'delete+insert', incremental_predicates = ['block_timestamp::date >= LEAST(current_date-7,(select min(block_timestamp)::date from ' ~ generate_tmp_view_name(this) ~ '))'], cluster_by = ['block_timestamp::DATE'], + post_hook = enable_search_optimization('{{this.schema}}','{{this.identifier}}','ON EQUALITY(tx_id,mint,mint_authority,token_account)'), tags = ['scheduled_non_core'] ) }}