dbt-coverage icon indicating copy to clipboard operation
dbt-coverage copied to clipboard

support generic tests from dbt_utils when calculating coverage

Open aa-matthias opened this issue 3 years ago • 5 comments
trafficstars

Our project is relying on tests defined in dbt_utils - is there a way of adding support for these as well?

https://github.com/dbt-labs/dbt-utils#unique_combination_of_columns-source

aa-matthias avatar Jun 18 '22 09:06 aa-matthias

@aa-matthias I presume these are currently not supported by dbt-coverage -- would that be the case?

Would you mind preparing a minimal example we could take a look at to better understand what would be needed to support these tests fully?

Thanks!

mrshu avatar Jul 30 '22 15:07 mrshu

Hi @mrshu - i've checked how tested columns are currently fetched in:

https://github.com/slidoapp/dbt-coverage/blob/main/dbt_coverage/init.py#L147

the problem is that for unique_combination_of_columns tests specified by dbt_utils kwargs are looking different - see the following example:

            "test_metadata": {
                "name": "unique_combination_of_columns",
                "kwargs": {
                    "combination_of_columns": [
                        "id",
                        "version_id"
                    ],
                    "model": "{{ get_where_subquery(ref('sw6_base_order')) }}"
                },
                "namespace": "dbt_utils"
            },

aa-matthias avatar Aug 20 '22 07:08 aa-matthias

I see, thanks @aa-matthias. I guess this would only concern the unique_combination_of_columns test though, right? All the others seem to be defined on the column level, which the dbt-coverage should be able to cover in its current version.

mrshu avatar Nov 03 '22 01:11 mrshu

yes, i think this is the only one - we're currently making use of these as there are several models have no single column primary key / unique key. however it looks like it's best practice to add these so maybe we'll do that instead than also giving us enough coverage.

aa-matthias avatar Nov 07 '22 10:11 aa-matthias

@aa-matthias, we are using the official dbt-docs logic to parse the tests. If you generate the documentation, does the test get marked correctly in the UI for the columns?

Screenshot 2022-11-21 at 17 37 22

sweco avatar Nov 21 '22 16:11 sweco