I’m test the logic for a new marco I have created based on the testing a new adapter document.
When I run the test it is failing on this part:
models__test_accepted_duplication_threshold_yml = “”"
version: 2
models:
- name: test_accepted_duplication_threshold
columns:- name: user_id
tests:- accepted_duplication_threshold:
accepted_threshold: 5
“”"
- accepted_duplication_threshold:
- name: user_id
Error snippet:
ERROR configured_file:functions.py:241 23:06:47.292220 [error] [MainThread]: Compilation Error in test accepted_duplication_threshold_test_accepted_duplication_threshold_5__user_id (models/test_accepted_duplication_threshold.yml)
ERROR configured_std_out:functions.py:241 23:06:47 Compilation Error in test accepted_duplication_threshold_test_accepted_duplication_threshold_5__user_id (models/test_accepted_duplication_threshold.yml)
ERROR configured_file:functions.py:241 23:06:47.292811 [error] [MainThread]: ‘test_accepted_duplication_threshold’ is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with “dbt deps”.
ERROR configured_std_out:functions.py:241 23:06:47 ‘test_accepted_duplication_threshold’ is undefined. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with “dbt deps”.
My macro is located in macros/generic_tests/test_accepted_duplication_threshold.sql.
{% test_accepted_duplication_threshold(model, column_name, accepted_threshold=0) %}
with validation_errors as (
select
{{ column_name }}
from {{ model }}
where {{ column_name }} is not null
group by {{ column_name }}
having count() > 1
),
aggregated as (
select
count() as n_errors
from validation_errors
group by 1
)
select
case
when n_errors <= {{ accepted_threshold }} then 0
else n_errors
end as result
from aggregated
{% endmacro %}
Wondering if someone knew how to let the test / environment know where this macro is?
Thanks