From 3eb02decfc785064ba811850d3299b85802039cb Mon Sep 17 00:00:00 2001 From: Alex Weseley Date: Thu, 24 Oct 2024 19:34:30 -0400 Subject: [PATCH] joe v2 tables incremental --- macros/trader_joe_v_2/trader_joe_v_2_1_swaps.sql | 3 +++ macros/trader_joe_v_2/trader_joe_v_2_2_swaps.sql | 3 +++ .../trader_joe/fact_trader_joe_arbitrum_v2_1_dex_swaps.sql | 2 +- .../trader_joe/fact_trader_joe_arbitrum_v2_2_dex_swaps.sql | 2 +- .../trader_joe/fact_trader_joe_avalanche_v2_1_dex_swaps.sql | 2 +- .../trader_joe/fact_trader_joe_avalanche_v2_2_dex_swaps.sql | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/macros/trader_joe_v_2/trader_joe_v_2_1_swaps.sql b/macros/trader_joe_v_2/trader_joe_v_2_1_swaps.sql index 7fa101d8..cbb71513 100644 --- a/macros/trader_joe_v_2/trader_joe_v_2_1_swaps.sql +++ b/macros/trader_joe_v_2/trader_joe_v_2_1_swaps.sql @@ -34,6 +34,9 @@ WITH lbpairs AS ( -- Step 1: Extract all Pools addresses that were create SELECT lbpair_address FROM lbpairs ) AND event_name = 'Swap' + {% if is_incremental() %} + AND block_timestamp > (SELECT MAX(block_timestamp) FROM {{this}}) + {% endif %} ) SELECT s.block_timestamp, diff --git a/macros/trader_joe_v_2/trader_joe_v_2_2_swaps.sql b/macros/trader_joe_v_2/trader_joe_v_2_2_swaps.sql index e9e5299e..53d0ced5 100644 --- a/macros/trader_joe_v_2/trader_joe_v_2_2_swaps.sql +++ b/macros/trader_joe_v_2/trader_joe_v_2_2_swaps.sql @@ -38,6 +38,9 @@ WHERE lbpairs ) AND topics[0] = '0xad7d6f97abf51ce18e17a38f4d70e975be9c0708474987bb3e26ad21bd93ca70' + {% if is_incremental() %} + AND block_timestamp > (SELECT MAX(block_timestamp) FROM {{this}}) + {% endif %} ) SELECT s.block_timestamp, diff --git a/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_1_dex_swaps.sql b/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_1_dex_swaps.sql index f21d1730..97957db6 100644 --- a/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_1_dex_swaps.sql +++ b/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_1_dex_swaps.sql @@ -1,6 +1,6 @@ {{ config( - materialized="table", + materialized="incremental", snowflake_warehouse="TRADER_JOE", ) }} diff --git a/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_2_dex_swaps.sql b/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_2_dex_swaps.sql index 8ad8d1fd..111e9c3e 100644 --- a/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_2_dex_swaps.sql +++ b/models/staging/trader_joe/fact_trader_joe_arbitrum_v2_2_dex_swaps.sql @@ -1,6 +1,6 @@ {{ config( - materialized="table", + materialized="incremental", snowflake_warehouse="TRADER_JOE", ) }} diff --git a/models/staging/trader_joe/fact_trader_joe_avalanche_v2_1_dex_swaps.sql b/models/staging/trader_joe/fact_trader_joe_avalanche_v2_1_dex_swaps.sql index 517efb3f..259bcab0 100644 --- a/models/staging/trader_joe/fact_trader_joe_avalanche_v2_1_dex_swaps.sql +++ b/models/staging/trader_joe/fact_trader_joe_avalanche_v2_1_dex_swaps.sql @@ -1,6 +1,6 @@ {{ config( - materialized="table", + materialized="incremental", snowflake_warehouse="TRADER_JOE", ) }} diff --git a/models/staging/trader_joe/fact_trader_joe_avalanche_v2_2_dex_swaps.sql b/models/staging/trader_joe/fact_trader_joe_avalanche_v2_2_dex_swaps.sql index a100e51a..be4a8384 100644 --- a/models/staging/trader_joe/fact_trader_joe_avalanche_v2_2_dex_swaps.sql +++ b/models/staging/trader_joe/fact_trader_joe_avalanche_v2_2_dex_swaps.sql @@ -1,6 +1,6 @@ {{ config( - materialized="table", + materialized="incremental", snowflake_warehouse="TRADER_JOE", ) }}