slidoapp / dbt-coverage

One-stop-shop for docs and test coverage of dbt projects.
MIT License
197 stars 25 forks source link

support generic tests from dbt_utils when calculating coverage #32

Open aa-matthias opened 2 years ago

aa-matthias commented 2 years ago

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

mrshu commented 2 years ago

@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!

aa-matthias commented 2 years ago

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"
            },
mrshu commented 2 years ago

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.

aa-matthias commented 2 years ago

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.

sweco commented 1 year ago

@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