From f6736fc13cd84bc3bb4ad2332464e939e8486505 Mon Sep 17 00:00:00 2001 From: Eric Laurello Date: Fri, 9 Sep 2022 10:54:10 -0400 Subject: [PATCH] clean up more testing --- models/core/core__fact_nft_sales.yml | 2 +- .../core__fact_transaction_participation.yml | 3 -- models/core/core__fact_transaction_reward.sql | 28 ++++++------------- models/core/core__fact_transaction_reward.yml | 20 ++----------- ...ver__transaction__intra-assert_no_gap.sql} | 0 5 files changed, 11 insertions(+), 42 deletions(-) rename tests/{silver_algorand__transactions__intra-assert_no_gap.sql => silver__transaction__intra-assert_no_gap.sql} (100%) diff --git a/models/core/core__fact_nft_sales.yml b/models/core/core__fact_nft_sales.yml index dfa4eec..5d89ecc 100644 --- a/models/core/core__fact_nft_sales.yml +++ b/models/core/core__fact_nft_sales.yml @@ -43,7 +43,7 @@ models: description: "" tests: - negative_one: - where: _inserted_timestamp < (CURRENT_TIMESTAMP - INTERVAL '8 HOURS') + where: _inserted_timestamp < (CURRENT_TIMESTAMP - INTERVAL '8 HOURS') AND NFT_ASSET_ID IS NULL - name: NUMBER_OF_NFTS description: "The amount on the NFT sold. In most cases this will be 1 but some NFTs have a token supply higher than 1" tests: diff --git a/models/core/core__fact_transaction_participation.yml b/models/core/core__fact_transaction_participation.yml index da24de9..58e9f1b 100644 --- a/models/core/core__fact_transaction_participation.yml +++ b/models/core/core__fact_transaction_participation.yml @@ -29,9 +29,6 @@ models: - not_null - name: DIM_ACCOUNT_ID description: "FK to the DIM_ACCOUNT table" - tests: - - negative_one: - where: _inserted_timestamp < (CURRENT_TIMESTAMP - INTERVAL '8 HOURS') - name: ADDRESS description: "{{ doc('address') }}" tests: diff --git a/models/core/core__fact_transaction_reward.sql b/models/core/core__fact_transaction_reward.sql index a7d1369..06a3ff0 100644 --- a/models/core/core__fact_transaction_reward.sql +++ b/models/core/core__fact_transaction_reward.sql @@ -1,6 +1,6 @@ {{ config( materialized = 'incremental', - unique_key = 'fact_transaction_close_id', + unique_key = 'fact_transaction_reward_id', incremental_strategy = 'merge', cluster_by = ['block_timestamp::DATE'] ) }} @@ -8,17 +8,14 @@ WITH base AS ( SELECT - block_id, - intra, - tx_group_id, - tx_id, - inner_tx, - account, - asset_id, - amount, + A.intra, + A.block_id, + A.tx_id, + A.account, + A.amount, _INSERTED_TIMESTAMP FROM - {{ ref('silver__transaction_close') }} + {{ ref('silver__transaction_reward') }} A {% if is_incremental() %} WHERE @@ -47,25 +44,19 @@ WHERE SELECT {{ dbt_utils.surrogate_key( ['a.block_id','a.intra','a.account'] - ) }} AS fact_transaction_close_id, + ) }} AS fact_transaction_reward_id, COALESCE( b.dim_block_id, '-1' ) AS dim_block_id, b.block_timestamp, intra, - tx_group_id, tx_id, - inner_tx, COALESCE( da.dim_account_id, '-1' ) AS dim_account_id, A.account AS address, - COALESCE( - dim_asset_id, - '-1' - ) AS dim_asset_id, amount, A._inserted_timestamp, '{{ env_var("DBT_CLOUD_RUN_ID", "manual") }}' AS _audit_run_id @@ -77,6 +68,3 @@ FROM LEFT JOIN {{ ref('core__dim_account') }} da ON A.account = da.address - LEFT JOIN {{ ref('core__dim_asset') }} - das - ON A.asset_id = das.asset_id diff --git a/models/core/core__fact_transaction_reward.yml b/models/core/core__fact_transaction_reward.yml index d467ae4..78d4f1a 100644 --- a/models/core/core__fact_transaction_reward.yml +++ b/models/core/core__fact_transaction_reward.yml @@ -3,7 +3,7 @@ models: - name: core__fact_transaction_reward description: "Fact table that contains all transaction closes with an amount > 0" columns: - - name: FACT_TRANSACTION_CLOSE_ID + - name: FACT_TRANSACTION_REWARD_ID description: "{{ doc('sk') }}" tests: - dbt_expectations.expect_column_to_exist @@ -24,16 +24,10 @@ models: description: "{{ doc('intra') }}" tests: - not_null - - name: TX_GROUP_ID - description: "{{ doc('tx_group_id') }}" - name: TX_ID description: "{{ doc('tx_id') }}" tests: - not_null - - name: INNER_TX - description: "{{ doc('inner_tx') }}" - tests: - - not_null - name: DIM_ACCOUNT_ID description: "FK to Dim_Account for the close account " tests: @@ -43,16 +37,11 @@ models: description: "{{ doc('address') }}" tests: - not_null - - name: DIM_ASSET_ID - description: "FK to Dim_Asset table" - tests: - - negative_one: - where: _inserted_timestamp < (CURRENT_TIMESTAMP - INTERVAL '8 HOURS') - name: AMOUNT description: "Amount of the asset being sent to the receiver" tests: - dbt_constraints.primary_key: - column_name: FACT_TRANSACTION_CLOSE_ID + column_name: FACT_TRANSACTION_REWARD_ID - dbt_constraints.foreign_key: fk_column_name: DIM_BLOCK_ID pk_table_name: ref('core__dim_block') @@ -61,9 +50,4 @@ models: fk_column_name: DIM_ACCOUNT_ID pk_table_name: ref('core__dim_account') pk_column_name: DIM_ACCOUNT_ID - - dbt_constraints.foreign_key: - fk_column_name: DIM_ASSET_ID - pk_table_name: ref('core__dim_asset') - pk_column_name: DIM_ASSET_ID - diff --git a/tests/silver_algorand__transactions__intra-assert_no_gap.sql b/tests/silver__transaction__intra-assert_no_gap.sql similarity index 100% rename from tests/silver_algorand__transactions__intra-assert_no_gap.sql rename to tests/silver__transaction__intra-assert_no_gap.sql