percentage test
This commit is contained in:
parent
8c96b96ee5
commit
15139e00d0
1 changed files with 10 additions and 0 deletions
10
macros/tests/is_valid_percentage.sql
Normal file
10
macros/tests/is_valid_percentage.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
The opinionated definition of a valid percentage for this macro:
|
||||||
|
- It is between 0 and 1 (including 0 and 1 as valid values).
|
||||||
|
*/
|
||||||
|
{% test is_valid_percentage(model, column_name) %}
|
||||||
|
with validation as (select {{ column_name }} as value from {{ model }})
|
||||||
|
select *
|
||||||
|
from validation
|
||||||
|
where value > 1 or value < -1
|
||||||
|
{% endtest %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue