Skip to content

Commit

Permalink
Use staging tables in test instead of source to handle test env
Browse files Browse the repository at this point in the history
  • Loading branch information
amishas157 committed Sep 12, 2024
1 parent 6bd6abf commit 74dad5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/bucketlist_db_size_check.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ with bucketlist_db_size as (
select sequence,
closed_at,
total_byte_size_of_bucket_list / 1000000000 as bl_db_gb
from {{ source('crypto_stellar', 'history_ledgers') }}
from {{ ref('stg_history_ledgers') }}
where closed_at >= TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 1 HOUR )
-- alert when the bucketlist has grown larger than 12 gb
and total_byte_size_of_bucket_list / 1000000000 >= 12
Expand Down
4 changes: 2 additions & 2 deletions tests/eho_by_ops.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ WITH find_missing AS (
SELECT op.id,
op.batch_run_date,
op.batch_id
FROM {{ source('crypto_stellar', 'history_operations') }} op
FROM {{ ref('stg_history_operations') }} op
LEFT OUTER JOIN {{ ref('enriched_history_operations') }} eho
ON op.id = eho.op_id
WHERE eho.op_id IS NULL
Expand All @@ -22,7 +22,7 @@ WITH find_missing AS (
),
find_max_batch AS (
SELECT MAX(batch_run_date) AS max_batch
FROM {{ source('crypto_stellar', 'history_operations') }}
FROM {{ ref('stg_history_operations') }}
WHERE TIMESTAMP(batch_run_date) >= TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 1 DAY )
)
SELECT batch_run_date,
Expand Down
2 changes: 1 addition & 1 deletion tests/ledger_sequence_increment.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with
, batch_id
, closed_at
, max(sequence) as max_sequence
from {{ source('crypto_stellar', 'history_ledgers') }}
from {{ ref('stg_history_ledgers') }}
where closed_at > TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 7 DAY )
group by id, batch_id, closed_at
)
Expand Down
8 changes: 4 additions & 4 deletions tests/num_txns_and_ops.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-- Get the actual count of transactions per ledger
WITH txn_count AS (
SELECT ledger_sequence, COUNT(id) as txn_transaction_count
FROM {{ source('crypto_stellar', 'history_transactions') }}
FROM {{ ref('stg_history_transactions') }}
--Take all ledgers committed in the last 36 hours to validate newly written data
-- Alert runs at 12pm UTC in GCP which creates the 36 hour interval
WHERE TIMESTAMP(batch_run_date) >= TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 1 DAY )
Expand All @@ -21,8 +21,8 @@ WITH txn_count AS (
-- Get the actual count of operations per ledger
operation_count AS (
SELECT A.ledger_sequence, COUNT(B.id) AS op_operation_count
FROM {{ source('crypto_stellar', 'history_transactions') }} A
JOIN {{ source('crypto_stellar', 'history_operations') }} B
FROM {{ ref('stg_history_transactions') }} A
JOIN {{ ref('stg_history_operations') }} B
ON A.id = B.transaction_id
WHERE TIMESTAMP(A.batch_run_date) >= TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 1 DAY )
AND TIMESTAMP(B.batch_run_date) >= TIMESTAMP_SUB('{{ dbt_airflow_macros.ts(timezone=none) }}', INTERVAL 1 DAY )
Expand All @@ -36,7 +36,7 @@ WITH txn_count AS (
(A.failed_transaction_count + A.successful_transaction_count) as expected_transaction_count,
COALESCE(B.txn_transaction_count, 0) as actual_transaction_count,
COALESCE(C.op_operation_count, 0) as actual_operation_count
FROM {{ source('crypto_stellar', 'history_ledgers') }} A
FROM {{ ref('stg_history_ledgers') }} A
LEFT OUTER JOIN txn_count B
ON A.sequence = B.ledger_sequence
LEFT OUTER JOIN operation_count C
Expand Down

0 comments on commit 74dad5a

Please sign in to comment.