Replies: 3 comments
-
A solution that we are trying for reporting-on/aggregating test results was to create a model for each test type. Basically we start with what do we want the final test schema to look like for reporting purposes and then rewrite it to match that. Then we use pattern matching to figure out what will need to be unioned together. This meant rewriting the default test. For not_null it looked something like the following.
The test is set in the
We also set Next a helper macro returns a list of nodes that start with a search string:
Finally a model is used to join all the not_null test results together:
From here we can create a model by hand that sums results of the 8 or so tests we are using across the project and organizes them by model, which sounds like where you need to end up. We were looking at potentially a thousand+ or so tests and trying to model by hand would be prohibitive. Ultimately, I think some of the observability tools might be a better approach for our needs but this seems to be working. We're only in the initial pass at this so not sure about scalability. And I welcome feedback on improvements! If there were a way to do this natively with dbt core as a test materialization that would be awesome! This isn't the first time I've worked with a client where we want to have one materialization of all test results, and ideally we wouldn't be modeling any of this after the fact. |
Beta Was this translation helpful? Give feedback.
-
I had a similar idea. Some of my models have many many generic tests! What if instead of each submitting a single SQL query, they submitted a single unioned query? I suspect this may be much faster in many circumstances. I am imaging this as (psuedocode):
And a model with a config like If persist test results is on, on fail, a post run hook or something could perhaps run the failing test to persist. |
Beta Was this translation helpful? Give feedback.
-
Linking to #4613. |
Beta Was this translation helpful? Give feedback.
-
It would be helpful if there was a way to combine tests that are materialized (
store_failures_as
) into a single object. For example if a dbt model had generic tests on a column for not null, unique and accepted values (leaving out relationship tests which will be harder), rather than storing each of those queries separately, they would be combined into something like:Then
tests/generic/builtin
would query that aggregate table to lookup each of the three tests. So checking the not null test for the model would be be:The problem is that this breaks the 1:1 nature of dbt tests. I understand how you would accomplish overriding the generic test queries but am less clear about how to first aggregate the tests into a single DDL command at the beginning of the test command.
Beta Was this translation helpful? Give feedback.
All reactions