From 176afbea2da285925a1835e50825b940cc427dae Mon Sep 17 00:00:00 2001 From: Mike Stepanovic Date: Fri, 26 Jul 2024 13:02:32 -0600 Subject: [PATCH 1/4] fixing a clock skew issue with silver__prices --- models/silver/silver__prices.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/silver/silver__prices.sql b/models/silver/silver__prices.sql index 7c3d8d7..df15616 100644 --- a/models/silver/silver__prices.sql +++ b/models/silver/silver__prices.sql @@ -46,7 +46,7 @@ price AS ( {% if is_incremental() %} WHERE - b.block_timestamp :: DATE >= ( + b.block_timestamp >= ( SELECT MAX( block_timestamp - INTERVAL '1 HOUR' From bb47faa0fef7eca56b03519ca40498817425bea2 Mon Sep 17 00:00:00 2001 From: Mike Stepanovic Date: Fri, 26 Jul 2024 13:12:34 -0600 Subject: [PATCH 2/4] fixes for 3 clock skews that slipped through --- models/silver/silver__daily_earnings.sql | 4 ++-- models/silver/silver__prices.sql | 2 +- models/silver/silver__total_block_rewards.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/models/silver/silver__daily_earnings.sql b/models/silver/silver__daily_earnings.sql index b6bac58..aa30d1a 100644 --- a/models/silver/silver__daily_earnings.sql +++ b/models/silver/silver__daily_earnings.sql @@ -23,7 +23,7 @@ WHERE block_timestamp :: DATE >= ( SELECT MAX( - DAY + DAY - INTERVAL '2 DAYS' --counteract clock skew ) FROM {{ this }} @@ -48,7 +48,7 @@ WHERE block_timestamp :: DATE >= ( SELECT MAX( - DAY + DAY - INTERVAL '2 DAYS' --counteract clock skew ) FROM {{ this }} diff --git a/models/silver/silver__prices.sql b/models/silver/silver__prices.sql index df15616..26ba807 100644 --- a/models/silver/silver__prices.sql +++ b/models/silver/silver__prices.sql @@ -23,7 +23,7 @@ WITH blocks AS ( {% if is_incremental() %} WHERE - b.block_timestamp :: DATE >= ( + b.block_timestamp >= ( SELECT MAX( block_timestamp - INTERVAL '1 HOUR' diff --git a/models/silver/silver__total_block_rewards.sql b/models/silver/silver__total_block_rewards.sql index 48154f8..4b1df58 100644 --- a/models/silver/silver__total_block_rewards.sql +++ b/models/silver/silver__total_block_rewards.sql @@ -95,7 +95,7 @@ FROM {% if is_incremental() %} WHERE ( - b.block_timestamp :: DATE >= ( + b.block_timestamp >= ( SELECT MAX( block_timestamp - INTERVAL '1 HOUR' From 9f0324acd55d1904ad35561ce880906d3712d1e6 Mon Sep 17 00:00:00 2001 From: Mike Stepanovic Date: Fri, 26 Jul 2024 14:06:21 -0600 Subject: [PATCH 3/4] changed clustering key for daily pool stats --- models/silver/silver__daily_pool_stats.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/silver/silver__daily_pool_stats.sql b/models/silver/silver__daily_pool_stats.sql index dbd21c9..24f0e78 100644 --- a/models/silver/silver__daily_pool_stats.sql +++ b/models/silver/silver__daily_pool_stats.sql @@ -2,7 +2,7 @@ materialized = 'incremental', unique_key = "_unique_key", incremental_strategy = 'merge', - cluster_by = ['block_timestamp::DATE'], + cluster_by = ['day'], incremental_predicates = ['DBT_INTERNAL_DEST.day >= (select min(day) from ' ~ generate_tmp_view_name(this) ~ ')'] ) }} From f95a65fbc2301420d5851a2c8f9fbb2448b26adc Mon Sep 17 00:00:00 2001 From: Mike Stepanovic Date: Fri, 26 Jul 2024 14:07:43 -0600 Subject: [PATCH 4/4] rewards fix --- models/silver/silver__block_rewards.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/silver/silver__block_rewards.sql b/models/silver/silver__block_rewards.sql index d5c0011..07d01ab 100644 --- a/models/silver/silver__block_rewards.sql +++ b/models/silver/silver__block_rewards.sql @@ -2,7 +2,7 @@ materialized = 'incremental', unique_key = 'day', incremental_strategy = 'merge', - cluster_by = ['block_timestamp::DATE'] + cluster_by = ['day'] ) }} WITH all_block_id AS (