From 18dbe62aba28a5768eddf81bbf2c77ec39170b19 Mon Sep 17 00:00:00 2001 From: Reuven Gonzales Date: Tue, 26 Mar 2024 10:13:56 -0700 Subject: [PATCH] Fixes for incremental runs (#1134) * Fixes for incremental runs * fix lint --- .../staging/ethereum/stg_ethereum__deployers.sql | 13 ++++++------- .../staging/optimism/stg_optimism__deployers.sql | 4 ++-- .../stg_ossd__artifacts_by_project.sql | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/warehouse/dbt/models/staging/ethereum/stg_ethereum__deployers.sql b/warehouse/dbt/models/staging/ethereum/stg_ethereum__deployers.sql index c29772c14..aa424cb32 100644 --- a/warehouse/dbt/models/staging/ethereum/stg_ethereum__deployers.sql +++ b/warehouse/dbt/models/staging/ethereum/stg_ethereum__deployers.sql @@ -25,10 +25,9 @@ WHERE AND receipt_status = 1 AND receipt_contract_address IS NOT NULL {% if is_incremental() %} - WHERE - TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( - SELECT TIMESTAMP_TRUNC(MAX(block_timestamp), DAY) - FROM {{ this }} - ) - AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() - {% endif %} + AND TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( + SELECT TIMESTAMP_TRUNC(MAX(block_timestamp), DAY) + FROM {{ this }} + ) + AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() +{% endif %} diff --git a/warehouse/dbt/models/staging/optimism/stg_optimism__deployers.sql b/warehouse/dbt/models/staging/optimism/stg_optimism__deployers.sql index 74e09821b..ee00b9331 100644 --- a/warehouse/dbt/models/staging/optimism/stg_optimism__deployers.sql +++ b/warehouse/dbt/models/staging/optimism/stg_optimism__deployers.sql @@ -42,8 +42,8 @@ INNER JOIN logs AS l WHERE t.to_address IS null {% if is_incremental() %} - AND TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( + AND TIMESTAMP_TRUNC(t.block_timestamp, DAY) >= ( SELECT * FROM max_block_timestamp ) - AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() + AND TIMESTAMP_TRUNC(t.block_timestamp, DAY) < CURRENT_TIMESTAMP() {% endif %} diff --git a/warehouse/dbt/models/staging/oss-directory/stg_ossd__artifacts_by_project.sql b/warehouse/dbt/models/staging/oss-directory/stg_ossd__artifacts_by_project.sql index 8dd0107aa..c584c5779 100644 --- a/warehouse/dbt/models/staging/oss-directory/stg_ossd__artifacts_by_project.sql +++ b/warehouse/dbt/models/staging/oss-directory/stg_ossd__artifacts_by_project.sql @@ -59,11 +59,11 @@ all_deployers AS ( SELECT *, 'OPTIMISM' AS network - FROM {{ ref("stg_ethereum__deployers") }} + FROM {{ ref("stg_optimism__deployers") }} UNION ALL SELECT *, - 'ETHEREUM' AS network + 'MAINNET' AS network FROM {{ ref("stg_ethereum__deployers") }} ),