clean up more testing

This commit is contained in:
Eric Laurello 2022-09-09 10:54:10 -04:00
parent 9704e3c5bd
commit f6736fc13c
5 changed files with 11 additions and 42 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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