mirror of
https://github.com/FlipsideCrypto/bsc-models.git
synced 2026-02-06 13:26:44 +00:00
tests (#81)
* tests * traces tweaks * tweak test and lookback * recent test yml * schedule * incremental * move decoder test * fix exclude * increase refresh
This commit is contained in:
parent
921120da90
commit
6d5d0709d3
@ -4,8 +4,8 @@ run-name: dbt_run_streamline_realtime
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Runs "every 2 hours" (see https://crontab.guru)
|
||||
- cron: '0 1-23/2 * * *'
|
||||
# Runs “At every 30th minute.” (see https://crontab.guru)
|
||||
- cron: '*/30 * * * *'
|
||||
|
||||
env:
|
||||
DBT_PROFILES_DIR: ./
|
||||
|
||||
4
.github/workflows/dbt_run_temp_backfill.yml
vendored
4
.github/workflows/dbt_run_temp_backfill.yml
vendored
@ -4,8 +4,8 @@ run-name: dbt_run_temp_backfill
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Runs "every 2 hours at minute 20" (see https://crontab.guru)
|
||||
- cron: '20 */2 * * *'
|
||||
# Runs every "At minute 10.” (see https://crontab.guru)
|
||||
- cron: '10 * * * *'
|
||||
|
||||
env:
|
||||
DBT_PROFILES_DIR: ./
|
||||
|
||||
2
.github/workflows/dbt_test.yml
vendored
2
.github/workflows/dbt_test.yml
vendored
@ -41,7 +41,7 @@ jobs:
|
||||
dbt deps
|
||||
- name: Run DBT Jobs
|
||||
run: |
|
||||
dbt test
|
||||
dbt test --exclude tag:full_test tag:recent_test
|
||||
|
||||
|
||||
|
||||
|
||||
47
.github/workflows/dbt_test_intraday.yml
vendored
Normal file
47
.github/workflows/dbt_test_intraday.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: dbt_test_intraday
|
||||
run-name: dbt_test_intraday
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Runs “At minute 15 past every 4th hour.” (see https://crontab.guru)
|
||||
- cron: '15 */4 * * *'
|
||||
|
||||
env:
|
||||
DBT_PROFILES_DIR: ./
|
||||
|
||||
ACCOUNT: "${{ vars.ACCOUNT }}"
|
||||
ROLE: "${{ vars.ROLE }}"
|
||||
USER: "${{ vars.USER }}"
|
||||
PASSWORD: "${{ secrets.PASSWORD }}"
|
||||
REGION: "${{ vars.REGION }}"
|
||||
DATABASE: "${{ vars.DATABASE }}"
|
||||
WAREHOUSE: "${{ vars.WAREHOUSE }}"
|
||||
SCHEMA: "${{ vars.SCHEMA }}"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}
|
||||
|
||||
jobs:
|
||||
run_dbt_jobs:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: workflow_prod
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: "3.7.x"
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
pip3 install dbt-snowflake==${{ vars.DBT_VERSION }} cli_passthrough requests click
|
||||
dbt deps
|
||||
- name: Run DBT Jobs
|
||||
run: |
|
||||
dbt test -m tag:recent_test
|
||||
|
||||
|
||||
|
||||
63
macros/tests/missing_txs.sql
Normal file
63
macros/tests/missing_txs.sql
Normal file
@ -0,0 +1,63 @@
|
||||
{% macro missing_txs(
|
||||
model
|
||||
) %}
|
||||
WITH txs_base AS (
|
||||
SELECT
|
||||
block_number AS base_block_number,
|
||||
tx_hash AS base_tx_hash
|
||||
FROM
|
||||
{{ ref('test_silver__transactions_full') }}
|
||||
),
|
||||
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 recent_missing_txs(
|
||||
model
|
||||
) %}
|
||||
WITH txs_base AS (
|
||||
SELECT
|
||||
block_number AS base_block_number,
|
||||
tx_hash AS base_tx_hash
|
||||
FROM
|
||||
{{ ref('test_silver__transactions_recent') }}
|
||||
),
|
||||
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 %}
|
||||
@ -6,7 +6,7 @@
|
||||
block_number,
|
||||
tx_count
|
||||
FROM
|
||||
{{ ref('silver__blocks') }}
|
||||
{{ ref('test_silver__blocks_full') }}
|
||||
),
|
||||
model_name AS (
|
||||
SELECT
|
||||
@ -29,5 +29,51 @@ FROM
|
||||
LEFT JOIN model_name
|
||||
ON block_base.block_number = model_name.block_number
|
||||
WHERE
|
||||
tx_count <> model_tx_count
|
||||
(
|
||||
tx_count <> model_tx_count
|
||||
)
|
||||
OR (
|
||||
model_tx_count IS NULL
|
||||
AND tx_count <> 0
|
||||
)
|
||||
{% endmacro %}
|
||||
|
||||
{% macro recent_tx_gaps(
|
||||
model
|
||||
) %}
|
||||
WITH block_base AS (
|
||||
SELECT
|
||||
block_number,
|
||||
tx_count
|
||||
FROM
|
||||
{{ ref('test_silver__blocks_recent') }}
|
||||
),
|
||||
model_name AS (
|
||||
SELECT
|
||||
block_number,
|
||||
COUNT(
|
||||
DISTINCT tx_hash
|
||||
) AS model_tx_count
|
||||
FROM
|
||||
{{ model }}
|
||||
GROUP BY
|
||||
block_number
|
||||
)
|
||||
SELECT
|
||||
block_base.block_number,
|
||||
tx_count,
|
||||
model_name.block_number AS model_block_number,
|
||||
model_tx_count
|
||||
FROM
|
||||
block_base
|
||||
LEFT JOIN model_name
|
||||
ON block_base.block_number = model_name.block_number
|
||||
WHERE
|
||||
(
|
||||
tx_count <> model_tx_count
|
||||
)
|
||||
OR (
|
||||
model_tx_count IS NULL
|
||||
AND tx_count <> 0
|
||||
)
|
||||
{% endmacro %}
|
||||
|
||||
@ -83,14 +83,12 @@ new_records AS (
|
||||
FROM
|
||||
flat_logs l
|
||||
LEFT OUTER JOIN {{ ref('silver__transactions2') }}
|
||||
txs USING (
|
||||
block_number,
|
||||
tx_hash
|
||||
)
|
||||
txs
|
||||
ON l.block_number = txs.block_number
|
||||
AND l.tx_hash = txs.tx_hash
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
txs._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
AND txs._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
|
||||
@ -257,8 +257,7 @@ flattened_traces AS (
|
||||
AND f.block_number = t.block_number
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
t._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
AND t._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
|
||||
@ -103,14 +103,13 @@ new_records AS (
|
||||
r
|
||||
ON A.block_number = r.block_number
|
||||
AND A.data :hash :: STRING = r.tx_hash
|
||||
LEFT OUTER JOIN {{ ref('silver__blocks2') }}
|
||||
b
|
||||
ON A.block_number = b.block_number
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
r._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
AND r._INSERTED_TIMESTAMP >= '{{ lookback() }}'
|
||||
{% endif %}
|
||||
LEFT OUTER JOIN {{ ref('silver__blocks2') }}
|
||||
b
|
||||
ON A.block_number = b.block_number
|
||||
)
|
||||
|
||||
{% if is_incremental() %},
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__blocks2') }}
|
||||
95
models/silver/core/tests/blocks/test_silver__blocks_full.yml
Normal file
95
models/silver/core/tests/blocks/test_silver__blocks_full.yml
Normal file
@ -0,0 +1,95 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__blocks_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- BLOCK_NUMBER
|
||||
- sequence_gaps:
|
||||
column_name: BLOCK_NUMBER
|
||||
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: DIFFICULTY
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_DIFFICULTY
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EXTRA_DATA
|
||||
tests:
|
||||
- not_null
|
||||
- name: GAS_LIMIT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: GAS_USED
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: PARENT_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: MINER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: NONCE
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- name: RECEIPTS_ROOT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SHA3_UNCLES
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SIZE
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__blocks2') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,27 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__blocks_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- BLOCK_NUMBER
|
||||
- sequence_gaps:
|
||||
column_name: BLOCK_NUMBER
|
||||
config:
|
||||
severity: error
|
||||
error_if: ">10"
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: hour
|
||||
interval: 3
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__logs2') }}
|
||||
@ -0,0 +1,77 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__logs_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
- TX_HASH
|
||||
column_name: EVENT_INDEX
|
||||
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- tx_block_count:
|
||||
config:
|
||||
severity: error
|
||||
error_if: "!=0"
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TOPICS
|
||||
tests:
|
||||
- not_null
|
||||
- name: DATA
|
||||
tests:
|
||||
- not_null
|
||||
- name: EVENT_REMOVED
|
||||
tests:
|
||||
- not_null
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__logs2') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,33 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__logs_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
- TX_HASH
|
||||
column_name: EVENT_INDEX
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: hour
|
||||
interval: 3
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__receipts') }}
|
||||
@ -0,0 +1,82 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__receipts_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_HASH
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: POSITION
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: POSITION
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- name: FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
where: TO_ADDRESS IS NOT NULL
|
||||
- name: BLOCK_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: CUMULATIVE_GAS_USED
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EFFECTIVE_GAS_PRICE
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: GAS_USED
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TX_STATUS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_set:
|
||||
value_set: ['SUCCESS', 'FAIL']
|
||||
- name: TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__receipts') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,28 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__receipts_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_HASH
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: POSITION
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: hour
|
||||
interval: 3
|
||||
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__traces2') }}
|
||||
59
models/silver/core/tests/traces/test_silver__traces_full.yml
Normal file
59
models/silver/core/tests/traces/test_silver__traces_full.yml
Normal file
@ -0,0 +1,59 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__traces_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- BLOCK_NUMBER
|
||||
- TX_POSITION
|
||||
- TRACE_INDEX
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: FROM_ADDRESS
|
||||
tests:
|
||||
- not_null:
|
||||
where: TYPE <> 'SELFDESTRUCT'
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
where: TO_ADDRESS IS NOT NULL
|
||||
- name: IDENTIFIER
|
||||
tests:
|
||||
- not_null
|
||||
- name: BNB_VALUE
|
||||
tests:
|
||||
- not_null
|
||||
- name: GAS
|
||||
tests:
|
||||
- not_null
|
||||
- name: GAS_USED
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__traces2') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,35 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__traces_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- BLOCK_NUMBER
|
||||
- TX_POSITION
|
||||
- TRACE_INDEX
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__transactions2') }}
|
||||
@ -0,0 +1,119 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__transactions_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_HASH
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: POSITION
|
||||
where: BLOCK_TIMESTAMP < CURRENT_DATE - 1
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: NONCE
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: POSITION
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- name: FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
where: TO_ADDRESS IS NOT NULL
|
||||
- name: VALUE
|
||||
tests:
|
||||
- not_null
|
||||
- name: BLOCK_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: GAS_PRICE
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: GAS
|
||||
tests:
|
||||
- not_null
|
||||
- name: INPUT_DATA
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_STATUS
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_be_in_set:
|
||||
value_set: ['SUCCESS', 'FAIL']
|
||||
where: NOT IS_PENDING
|
||||
- name: GAS_USED
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CUMULATIVE_GAS_USED
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TX_FEE
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EFFECTIVE_GAS_PRICE
|
||||
tests:
|
||||
- not_null:
|
||||
where: NOT IS_PENDING
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__transactions2') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
@ -0,0 +1,22 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__transactions_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_HASH
|
||||
- sequence_gaps:
|
||||
partition_by:
|
||||
- BLOCK_NUMBER
|
||||
column_name: POSITION
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: hour
|
||||
interval: 3
|
||||
|
||||
9
models/silver/tests/test_silver__decoded_logs_full.sql
Normal file
9
models/silver/tests/test_silver__decoded_logs_full.sql
Normal file
@ -0,0 +1,9 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['full_test']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__decoded_logs') }}
|
||||
@ -1,6 +1,6 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__decoded_logs
|
||||
- name: test_silver__decoded_logs_full
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
27
models/silver/tests/test_silver__decoded_logs_recent.sql
Normal file
27
models/silver/tests/test_silver__decoded_logs_recent.sql
Normal file
@ -0,0 +1,27 @@
|
||||
{{ config (
|
||||
materialized = 'view',
|
||||
tags = ['recent_test']
|
||||
) }}
|
||||
|
||||
WITH last_3_days AS (
|
||||
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
{{ ref("_max_block_by_date") }}
|
||||
qualify ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
block_number DESC
|
||||
) = 3
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__decoded_logs') }}
|
||||
WHERE
|
||||
block_number >= (
|
||||
SELECT
|
||||
block_number
|
||||
FROM
|
||||
last_3_days
|
||||
)
|
||||
52
models/silver/tests/test_silver__decoded_logs_recent.yml
Normal file
52
models/silver/tests/test_silver__decoded_logs_recent.yml
Normal file
@ -0,0 +1,52 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: test_silver__decoded_logs_recent
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- dbt_utils.recency:
|
||||
datepart: day
|
||||
field: _INSERTED_TIMESTAMP
|
||||
interval: 1
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
tests/bsc/test_silver__missing_receipts.sql
Normal file
2
tests/bsc/test_silver__missing_receipts.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__transactions_full') }}
|
||||
{{ missing_txs(ref("test_silver__receipts_full")) }}
|
||||
2
tests/bsc/test_silver__missing_traces.sql
Normal file
2
tests/bsc/test_silver__missing_traces.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__transactions_full') }}
|
||||
{{ missing_txs(ref("test_silver__traces_full")) }}
|
||||
2
tests/bsc/test_silver__missing_txs.sql
Normal file
2
tests/bsc/test_silver__missing_txs.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__blocks_full') }}
|
||||
{{ tx_gaps(ref("test_silver__transactions_full")) }}
|
||||
2
tests/bsc/test_silver__recent_missing_receipts.sql
Normal file
2
tests/bsc/test_silver__recent_missing_receipts.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__transactions_recent') }}
|
||||
{{ recent_missing_txs(ref("test_silver__receipts_recent")) }}
|
||||
2
tests/bsc/test_silver__recent_missing_traces.sql
Normal file
2
tests/bsc/test_silver__recent_missing_traces.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__transactions_recent') }}
|
||||
{{ recent_missing_txs(ref("test_silver__traces_recent")) }}
|
||||
2
tests/bsc/test_silver__recent_missing_txs.sql
Normal file
2
tests/bsc/test_silver__recent_missing_txs.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- depends_on: {{ ref('test_silver__blocks_recent') }}
|
||||
{{ recent_tx_gaps(ref("test_silver__transactions_recent")) }}
|
||||
@ -1,2 +0,0 @@
|
||||
-- depends_on: {{ ref('silver__blocks') }}
|
||||
{{ tx_gaps(ref("silver__transactions")) }}
|
||||
Loading…
Reference in New Issue
Block a user