I made a reduced and redacted version that could be used for testing; adding or removing the comment determines whether the error appears.
Oh, and I forgot to mention I’m using snowflake plugin, 1.5.1.
{% test valid_widgets(model, column_name, row_condition, allow_gizmo = True) %}
-- {{ ref('widgets') }}
-- remove the above comment to see the error
with widgets_filtered as (
select widget
from {{ ref('widgets') }}
{%- if not allow_gizmo %}
where widget <> 'gizmo'
{% endif %}
)
select {{ column_name }}
from {{ model }}
where
{{ column_name }} is not null
and
{{ column_name }} not in (select widget from widgets_filtered)
{%- if row_condition %}
and
{{ row_condition }}
{% endif %}
{% endtest %}
The reference does not appear like it’s in a conditional position, right?