solana-models/tests/test_streamline__complete_block_txs__gaps.sql
desmond-hui a3b8cf8458
Deprecate legacy block txs pipeline (#735)
* move to backfill folder

* remove legacy udfs and calls

* use streamline 2.0 data after cutover block & partition

* update start block to do checks, add streamline 2.0 data

* fix ambiguous reference

* this test isnt used, it is currently ignored in the test workflow

* get partition from streamline 2.0 upstream when available

* add TODOs

* update partition and block cutoffs
2024-12-12 15:40:01 -08:00

69 lines
1.7 KiB
SQL

{% set cutover_block_id = 307103862 %}
{% set cutover_partition_id = 150215 %}
{% set start_block_id = 306000000 %}
WITH base_blocks AS (
SELECT
*
FROM
{% if target.database == 'SOLANA' %}
solana.silver.blocks
{% else %}
solana_dev.silver.blocks
{% endif %}
WHERE
block_id >= {{ start_block_id }}
AND _inserted_date < CURRENT_DATE
),
base_txs AS (
SELECT
DISTINCT block_id
FROM
{% if target.database == 'SOLANA' %}
solana.silver.transactions
{% else %}
solana_dev.silver.transactions
{% endif %}
WHERE
block_id >= {{ start_block_id }}
UNION
SELECT
DISTINCT block_id
FROM
{% if target.database == 'SOLANA' %}
solana.silver.votes
{% else %}
solana_dev.silver.votes
{% endif %}
WHERE
block_id >= {{ start_block_id }}
),
potential_missing_txs AS (
SELECT
base_blocks.*
FROM
base_blocks
LEFT OUTER JOIN base_txs
ON base_blocks.block_id = base_txs.block_id
WHERE
base_txs.block_id IS NULL
)
SELECT
m.block_id
FROM
potential_missing_txs m
LEFT OUTER JOIN {{ ref('streamline__complete_block_txs') }} cmp
ON m.block_id = cmp.block_id
LEFT OUTER JOIN {{ ref('streamline__complete_block_txs_2') }} cmp2
ON m.block_id = cmp2.block_id
WHERE
(
m.block_id < {{ cutover_block_id }} -- cutover block id from silver__transactions
AND (cmp.error IS NOT NULL OR cmp.block_id IS NULL)
)
OR (
m.block_id >= {{ cutover_block_id }}
AND cmp2._partition_id >= {{ cutover_partition_id }}
AND (cmp2.block_id IS NULL)
)