diff --git a/macros/tests/null_threshold.sql b/macros/tests/null_threshold.sql new file mode 100644 index 0000000..cf5840a --- /dev/null +++ b/macros/tests/null_threshold.sql @@ -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 %} diff --git a/models/gold/defi/lending/defi__ez_lending_liquidations.yml b/models/gold/defi/lending/defi__ez_lending_liquidations.yml index bc6e4e3..c1cb510 100644 --- a/models/gold/defi/lending/defi__ez_lending_liquidations.yml +++ b/models/gold/defi/lending/defi__ez_lending_liquidations.yml @@ -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') }}"