Skip to content

Commit

Permalink
add SO; convert gold views with union to table
Browse files Browse the repository at this point in the history
  • Loading branch information
tarikceric committed Jul 17, 2024
1 parent aa85c99 commit 78f9775
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 2 deletions.
57 changes: 55 additions & 2 deletions models/gold/defi/defi__fact_stake_pool_actions.sql
Original file line number Diff line number Diff line change
@@ -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']
) }}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -164,3 +209,11 @@ FROM
{{ ref(
'silver__stake_pool_actions_jito'
) }}
{% if is_incremental() %}
WHERE modified_timestamp >= (
SELECT
MAX(modified_timestamp)
FROM
{{ this }}
)
{% endif %}
2 changes: 2 additions & 0 deletions models/silver/bridges/silver__bridge_debridge_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
1 change: 1 addition & 0 deletions models/silver/bridges/silver__bridge_mayan_transfers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
1 change: 1 addition & 0 deletions models/silver/prices/silver__complete_native_prices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'complete_native_prices_id',
cluster_by = ['HOUR::DATE'],
tags = ['scheduled_non_core']
) }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
2 changes: 2 additions & 0 deletions models/silver/prices/silver__complete_provider_prices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
2 changes: 2 additions & 0 deletions models/silver/prices/silver__complete_token_prices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
1 change: 1 addition & 0 deletions models/silver/silver__blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
) }}

Expand Down
1 change: 1 addition & 0 deletions models/silver/tokens/silver__token_burn_actions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down
1 change: 1 addition & 0 deletions models/silver/tokens/silver__token_mint_actions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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']
) }}

Expand Down

0 comments on commit 78f9775

Please sign in to comment.