The problem I’m having
I have a config block inside of my model, where I want to add a test so that it can be run after the model is built.
The context of why I’m trying to do this
I want to run certain tests during development at each model level.
What I’ve already tried
– tests/compare_row_counts.sql
{% test compare_row_counts(model, prod_schema, prod_table) %}
with model_count as (
select count(*) as cnt from {{ model }}
),
prod_count as (
select count(*) as cnt from {{ prod_schema }}.{{ prod_table }}
),
validation as (
select
model_count.cnt as model_count,
prod_count.cnt as prod_count
from model_count, prod_count
)
select *
from validation
where model_count != prod_count
{% endtest %}
models/my_model.sql
...
{{
config(
tags: ...,
materialized: ....,
tests: [
{
'compare_row_counts': {
'prod_schema': 'PROD_SCH',
'prod_table': 'PROD_TBL',
}
}
],
)
}}
When I build or test my model, it doesn’t run the tests.
Is there a way to specify tests at a model level.
Thank you.