From cb4b3db6e118c545637303c8983adf9e6c35dcf1 Mon Sep 17 00:00:00 2001 From: Jack Forgash Date: Mon, 21 Aug 2023 21:07:54 -0600 Subject: [PATCH] add qualify to take latest hash --- .../streamline/realtime/streamline__blocks_realtime.sql | 6 +++++- .../realtime/streamline__transactions_realtime.sql | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/models/silver/streamline/realtime/streamline__blocks_realtime.sql b/models/silver/streamline/realtime/streamline__blocks_realtime.sql index 7e0afa0f..b90962dc 100644 --- a/models/silver/streamline/realtime/streamline__blocks_realtime.sql +++ b/models/silver/streamline/realtime/streamline__blocks_realtime.sql @@ -45,7 +45,11 @@ WITH last_3_days AS ({% if var('STREAMLINE_RUN_HISTORY') %} last_3_days ) AND block_number IS NOT NULL - ) + ) qualify ROW_NUMBER() over ( + PARTITION BY block_number + ORDER BY + _inserted_timestamp DESC + ) = 1 ) SELECT block_number, diff --git a/models/silver/streamline/realtime/streamline__transactions_realtime.sql b/models/silver/streamline/realtime/streamline__transactions_realtime.sql index 57f39f26..86cfa6b3 100644 --- a/models/silver/streamline/realtime/streamline__transactions_realtime.sql +++ b/models/silver/streamline/realtime/streamline__transactions_realtime.sql @@ -45,7 +45,11 @@ WITH last_3_days AS ({% if var('STREAMLINE_RUN_HISTORY') %} last_3_days ) AND block_number IS NOT NULL - ) + ) qualify ROW_NUMBER() over ( + PARTITION BY block_number + ORDER BY + _inserted_timestamp DESC + ) = 1 ) SELECT block_number,