-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use test materialization when executing ✨generic✨ tests #3192
Comments
Hello!
I want it to fail if I have more than n errors, and to know how many errors they were. It was easy before, since we retrieved the value of count(*). We have several tests this way, so actually we'd rather stay with the old testing mode. Is there a way of choosing the testing method somewhere (e.g.: dbt_project.yml)? |
@ezequielberto I'm hopeful that a migration to the new testing mechanisms in v0.20 is smoother than it may first appear. In fact, I think you have some options.
with validation_errors as (
select
left_.id as left_id,
right_.id as right_id
from (select {{ column_name }} as id from {{ model }}) as left_
left join (select {{ field }} as id from {{ to }}) as right_
on left_.id = right_.id
where left_.id is not null
and right_.id is null
)
select * from validation_errors Then replace relationships:
to: ...
field: ...
error_if: 10
warn_if: 50
select * from count_errors
where n_errors > {{ tolerate_errors }} |
Current Behavior
generic (aka schema) tests are currently executed using the python api directly.
https://github.com/fishtown-analytics/dbt/blob/77c10713a325d2bee91d1822951ce5d91ccc3278/core/dbt/task/test.py#L84-L85
Desired Behavior
Schema tests should be executed and handled by the same test materialization used for data tests. The goal here is to maintain existing behavior handling results (simply interpreting number of rows returned by
count(*)
for the test)Things to consider
Returning results for most schema tests is straight forward, we can simply remove
count(*)
and return the results of the query fulfilling the test, the materialization will take care of the rest. In some cases, this is not straight forward for tests that are simple pass/fail and do not necessarily return results.Example:
https://github.com/fishtown-analytics/dbt/blob/749f87397ec1e0a270b2e09bd8dbeb71862fdb81/test/integration/005_simple_seed_test/macros/schema_test.sql
We will have to create a way to interpret different types of results as part of this.
The text was updated successfully, but these errors were encountered: