diff --git a/.github/workflows/dbt_test.yml b/.github/workflows/dbt_test.yml index 66ebe85..2f901c6 100644 --- a/.github/workflows/dbt_test.yml +++ b/.github/workflows/dbt_test.yml @@ -43,6 +43,7 @@ jobs: - name: Run DBT Jobs run: | dbt test -s models/gold + dbt test -s tests__final_gaps continue-on-error: true - name: Log test results diff --git a/tests/tests__chunk_gaps.sql b/tests/tests__chunk_gaps.sql index a11f5a1..3ced898 100644 --- a/tests/tests__chunk_gaps.sql +++ b/tests/tests__chunk_gaps.sql @@ -1,7 +1,5 @@ {{ config( - error_if = '>=10', - warn_if = 'BETWEEN 1 AND 9', - tags = ['gap_test'] + severity = "error" ) }} WITH blocks AS ( diff --git a/tests/tests__final_gaps.sql b/tests/tests__final_gaps.sql new file mode 100644 index 0000000..37cbcd2 --- /dev/null +++ b/tests/tests__final_gaps.sql @@ -0,0 +1,69 @@ +{{ config( + severity = "error" +) }} + + +WITH r_receipts AS ( + SELECT + DISTINCT receipt_id, + block_id + FROM + {{ ref('silver__streamline_receipts') }} + WHERE + _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days' AND SYSDATE() - INTERVAL '24 hour' +), +f_receipts AS ( + SELECT + DISTINCT receipt_object_id, + block_id + FROM + {{ ref('silver__streamline_receipts_final') }} + WHERE + _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days' AND SYSDATE() - INTERVAL '24 hour' +), +r_transactions AS ( + SELECT + DISTINCT tx_hash, + block_id + FROM + {{ ref('silver__streamline_transactions') }} + WHERE + _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days' AND SYSDATE() - INTERVAL '24 hour' + AND + _actions[0] is not null +), +f_transactions AS ( + SELECT + DISTINCT tx_hash, + block_id + FROM + {{ ref('silver__streamline_transactions_final') }} + WHERE + _inserted_timestamp BETWEEN SYSDATE() - INTERVAL '7 days' AND SYSDATE() - INTERVAL '24 hour' +) + +SELECT + r_receipts.receipt_id AS missing, + r_receipts.block_id +FROM + r_receipts +LEFT JOIN + f_receipts +ON + r_receipts.receipt_id = f_receipts.receipt_object_id +WHERE + f_receipts.receipt_object_id IS NULL + +UNION ALL + +SELECT + r_transactions.tx_hash AS missing, + r_transactions.block_id +FROM + r_transactions +LEFT JOIN + f_transactions +ON + r_transactions.tx_hash = f_transactions.tx_hash +WHERE + f_transactions.tx_hash IS NULL