mirror of
https://github.com/FlipsideCrypto/aptos-models.git
synced 2026-02-06 15:47:11 +00:00
Merge pull request #77 from FlipsideCrypto/update/liquidation_testing
add null threshold test
This commit is contained in:
commit
d1682be53b
32
macros/tests/null_threshold.sql
Normal file
32
macros/tests/null_threshold.sql
Normal 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 %}
|
||||
@ -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') }}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user