diff --git a/macros/tests/is_valid_percentage.sql b/macros/tests/is_valid_percentage.sql new file mode 100644 index 0000000..4e90ab9 --- /dev/null +++ b/macros/tests/is_valid_percentage.sql @@ -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 %}