update missing txns

This commit is contained in:
drethereum 2024-07-09 09:37:45 -06:00
parent 45c8a381a2
commit 2ef2dda8b7
4 changed files with 87 additions and 5 deletions

View File

@ -1,5 +1,6 @@
{% macro missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -7,6 +8,9 @@
tx_hash AS base_tx_hash
FROM
{{ ref('test_silver__transactions_full') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
@ -33,7 +37,8 @@ WHERE
{% endmacro %}
{% macro recent_missing_txs(
model
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
@ -41,6 +46,83 @@ WHERE
tx_hash AS base_tx_hash
FROM
{{ ref('test_silver__transactions_recent') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
block_number AS model_block_number,
tx_hash AS model_tx_hash
FROM
{{ model }}
)
SELECT
base_block_number,
base_tx_hash,
model_block_number,
model_tx_hash
FROM
txs_base
LEFT JOIN model_name
ON base_block_number = model_block_number
AND base_tx_hash = model_tx_hash
WHERE
model_tx_hash IS NULL
OR model_block_number IS NULL
{% endmacro %}
{% macro gold_missing_txs(
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
block_number AS base_block_number,
tx_hash AS base_tx_hash
FROM
{{ ref('test_gold__transactions_full') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT
block_number AS model_block_number,
tx_hash AS model_tx_hash
FROM
{{ model }}
)
SELECT
base_block_number,
base_tx_hash,
model_block_number,
model_tx_hash
FROM
txs_base
LEFT JOIN model_name
ON base_block_number = model_block_number
AND base_tx_hash = model_tx_hash
WHERE
(
model_tx_hash IS NULL
OR model_block_number IS NULL
)
{% endmacro %}
{% macro gold_recent_missing_txs(
model,
where_clause=None
) %}
WITH txs_base AS (
SELECT
block_number AS base_block_number,
tx_hash AS base_tx_hash
FROM
{{ ref('test_gold__transactions_recent') }}
{% if where_clause %}
WHERE {{ where_clause }}
{% endif %}
),
model_name AS (
SELECT

View File

@ -1,2 +1,2 @@
-- depends_on: {{ ref('test_silver__transactions_full') }}
{{ missing_txs(ref("test_gold__traces_full")) }}
{{ gold_missing_txs(ref("test_gold__traces_full")) }}

View File

@ -0,0 +1,2 @@
-- depends_on: {{ ref('test_silver__transactions_recent') }}
{{ gold_recent_missing_txs(ref("test_gold__traces_recent")) }}

View File

@ -1,2 +0,0 @@
-- depends_on: {{ ref('test_silver__transactions_recent') }}
{{ recent_missing_txs(ref("test_gold__traces_recent")) }}