From ea313f60ffb1c8923ff1ca9e7189ccb0e194dc12 Mon Sep 17 00:00:00 2001 From: desmond-hui <97470747+desmond-hui@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:26:08 -0700 Subject: [PATCH] add merge predicate to improve incremental run times (#370) --- models/silver/nfts/silver__nft_mint_actions.sql | 1 + models/silver/silver__mint_actions.sql | 1 + models/silver/tokens/silver__token_mint_actions.sql | 1 + 3 files changed, 3 insertions(+) diff --git a/models/silver/nfts/silver__nft_mint_actions.sql b/models/silver/nfts/silver__nft_mint_actions.sql index 3384d72c2..8ff0140d0 100644 --- a/models/silver/nfts/silver__nft_mint_actions.sql +++ b/models/silver/nfts/silver__nft_mint_actions.sql @@ -2,6 +2,7 @@ materialized = 'incremental', unique_key = "CONCAT_WS('-', tx_id, index, inner_index, mint)", 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'], ) }} diff --git a/models/silver/silver__mint_actions.sql b/models/silver/silver__mint_actions.sql index 339ca1930..7af3aa046 100644 --- a/models/silver/silver__mint_actions.sql +++ b/models/silver/silver__mint_actions.sql @@ -2,6 +2,7 @@ materialized = 'incremental', unique_key = "CONCAT_WS('-', tx_id, event_type, mint)", 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','_inserted_timestamp::DATE'] ) }} diff --git a/models/silver/tokens/silver__token_mint_actions.sql b/models/silver/tokens/silver__token_mint_actions.sql index dfadf509e..f6c19884f 100644 --- a/models/silver/tokens/silver__token_mint_actions.sql +++ b/models/silver/tokens/silver__token_mint_actions.sql @@ -2,6 +2,7 @@ materialized = 'incremental', unique_key = "CONCAT_WS('-', tx_id, index, inner_index, mint)", 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'], ) }}