flow-models/macros/tests/tx_gaps.sql
Jack Forgash edb39921fa
AN-1807/store tests (#53)
* store tests

* dbt 1.2

* test names and off for ingested at
2022-08-19 14:13:02 -06:00

36 lines
757 B
SQL

{% test tx_gaps(
model,
column_name,
column_block,
column_tx_count
) %}
WITH block_base AS (
SELECT
{{ column_block }},
{{ column_tx_count }}
FROM
{{ ref('silver__blocks') }}
),
model_name AS (
SELECT
{{ column_block }},
COUNT(
DISTINCT {{ column_name }}
) AS model_tx_count
FROM
{{ model }}
GROUP BY
{{ column_block }}
)
SELECT
block_base.{{ column_block }},
{{ column_tx_count }},
model_name.{{ column_block }} AS model_block_number,
model_tx_count
FROM
block_base
LEFT JOIN model_name
ON block_base.{{ column_block }} = model_name.{{ column_block }}
WHERE
{{ column_tx_count }} <> model_tx_count {% endtest %}