From 1b05690209a03eaa0f3f93a34ac1abeb1c6bd022 Mon Sep 17 00:00:00 2001 From: Matt Romano <42412983+mattromano@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:15:41 -0800 Subject: [PATCH] AN-4129/fix-long-running-daily-tests (#97) * transfer tests * add missing test --- .../transfers/test_silver__transfers_full.sql | 9 +++ .../test_silver__transfers_full.yml} | 6 +- .../test_silver__transfers_recent.sql | 27 ++++++++ .../test_silver__transfers_recent.yml | 67 +++++++++++++++++++ 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 models/silver/core/tests/transfers/test_silver__transfers_full.sql rename models/silver/core/{silver__transfers.yml => tests/transfers/test_silver__transfers_full.yml} (96%) create mode 100644 models/silver/core/tests/transfers/test_silver__transfers_recent.sql create mode 100644 models/silver/core/tests/transfers/test_silver__transfers_recent.yml diff --git a/models/silver/core/tests/transfers/test_silver__transfers_full.sql b/models/silver/core/tests/transfers/test_silver__transfers_full.sql new file mode 100644 index 00000000..487722dc --- /dev/null +++ b/models/silver/core/tests/transfers/test_silver__transfers_full.sql @@ -0,0 +1,9 @@ +{{ config ( + materialized = 'view', + tags = ['full_test'] +) }} + +SELECT + * +FROM + {{ ref('silver__transfers') }} diff --git a/models/silver/core/silver__transfers.yml b/models/silver/core/tests/transfers/test_silver__transfers_full.yml similarity index 96% rename from models/silver/core/silver__transfers.yml rename to models/silver/core/tests/transfers/test_silver__transfers_full.yml index 7b597dba..fe05c444 100644 --- a/models/silver/core/silver__transfers.yml +++ b/models/silver/core/tests/transfers/test_silver__transfers_full.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: silver__transfers + - name: test_silver__transfers_full tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -65,4 +65,6 @@ models: - name: ORIGIN_TO_ADDRESS tests: - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ \ No newline at end of file + regex: 0[xX][0-9a-fA-F]+ + + diff --git a/models/silver/core/tests/transfers/test_silver__transfers_recent.sql b/models/silver/core/tests/transfers/test_silver__transfers_recent.sql new file mode 100644 index 00000000..32af55a9 --- /dev/null +++ b/models/silver/core/tests/transfers/test_silver__transfers_recent.sql @@ -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__transfers') }} +WHERE + block_number >= ( + SELECT + block_number + FROM + last_3_days + ) diff --git a/models/silver/core/tests/transfers/test_silver__transfers_recent.yml b/models/silver/core/tests/transfers/test_silver__transfers_recent.yml new file mode 100644 index 00000000..99d65d12 --- /dev/null +++ b/models/silver/core/tests/transfers/test_silver__transfers_recent.yml @@ -0,0 +1,67 @@ +version: 2 +models: + - name: test_silver__transfers_recent + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - _LOG_ID + 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_NTZ + - name: TX_HASH + tests: + - not_null + - dbt_expectations.expect_column_values_to_match_regex: + regex: 0[xX][0-9a-fA-F]+ + - name: CONTRACT_ADDRESS + tests: + - not_null + - dbt_expectations.expect_column_values_to_match_regex: + regex: 0[xX][0-9a-fA-F]+ + - name: FROM_ADDRESS + tests: + - not_null: + where: BLOCK_TIMESTAMP > '2021-08-01' + - dbt_expectations.expect_column_values_to_match_regex: + regex: 0[xX][0-9a-fA-F]+ + - name: TO_ADDRESS + tests: + - not_null + - dbt_expectations.expect_column_values_to_match_regex: + regex: 0[xX][0-9a-fA-F]+ + - name: RAW_AMOUNT + tests: + - not_null + - dbt_expectations.expect_column_values_to_be_in_type_list: + column_type_list: + - NUMBER + - FLOAT + - name: _LOG_ID + tests: + - not_null + - name: ORIGIN_FUNCTION_SIGNATURE + tests: + - not_null + - 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]+ \ No newline at end of file