Merge pull request #77 from FlipsideCrypto/update/liquidation_testing

add null threshold test
This commit is contained in:
tarikceric 2025-10-24 11:21:12 -07:00 committed by GitHub
commit d1682be53b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 3 deletions

View File

@ -0,0 +1,32 @@
{% test null_threshold(
model,
column_name,
threshold_percent
) %}
-- threshold_percent: decimal representing percent of values that should NOT be null
WITH t AS (
SELECT
COUNT(*) * {{ threshold_percent }} AS threshold_num
FROM
{{ model }}
),
C AS (
SELECT
COUNT(*) AS cnt
FROM
{{ model }}
WHERE
{{ column_name }} IS NOT NULL
)
SELECT
*
FROM
C
WHERE
C.cnt <= (
SELECT
MAX(threshold_num)
FROM
t
)
{% endtest %}

View File

@ -71,7 +71,9 @@ models:
- name: COLLATERAL_TOKEN_SYMBOL
description: "{{ doc('symbol') }}"
tests:
- not_null: *recent_date_filter
- null_threshold:
threshold_percent: 0.90
where: block_timestamp >= current_date - 7 AND platform != 'echo'
- name: COLLATERAL_TOKEN_IS_VERIFIED
description: "{{ doc('prices_is_verified') }}"
tests:
@ -79,7 +81,8 @@ models:
- name: DEBT_TOKEN_SYMBOL
description: "{{ doc('symbol') }}"
tests:
- not_null:
- null_threshold:
threshold_percent: 0.90
where: block_timestamp >= current_date - 7 AND platform != 'echo'
- name: DEBT_TOKEN_IS_VERIFIED
description: "{{ doc('prices_is_verified') }}"
@ -96,7 +99,8 @@ models:
- name: AMOUNT_USD
description: "{{ doc('amount_usd') }}"
tests:
- not_null:
- null_threshold:
threshold_percent: 0.90
where: block_timestamp >= current_date - 7 AND platform != 'echo'
- name: EZ_LENDING_LIQUIDATIONS_ID
description: "{{ doc('pk') }}"