A package for computing coverage of dbt-managed data warehouses
Project description
dbt-coverage
A CLI library with Python backend for computing docs and test coverage of dbt managed data warehouses.
Installation
pip install dbt-coverage
Usage
dbt-coverage comes with two basic commands: compute and compare. The
documentation for the individual commands can be shown by using the --help
option.
Compute
Compute coverage from target/catalog.json and target/manifest.json files
found in a dbt project, e.g.
jaffle_shop. You need to select
documentation or test coverage by using the respective CLI argument.
$ cd jaffle_shop
$ dbt run # Materialize models
$ dbt docs generate # Generate catalog.json and manifest.json
$ dbt-coverage compute doc # Compute doc coverage, print it and write it to coverage.json file
# Coverage report
# =====================================================================
# customers 6/7 85.7%
# orders 9/9 100.0%
# raw_customers 0/3 0.0%
# raw_orders 0/4 0.0%
# raw_payments 0/4 0.0%
# stg_customers 0/3 0.0%
# stg_orders 0/4 0.0%
# stg_payments 0/4 0.0%
# =====================================================================
# Total 15/38 39.5%
$ dbt-coverage compute test # Compute test coverage, print it and write it to coverage.json file
# Coverage report
# =====================================================================
# customers 1/7 14.3%
# orders 8/9 88.9%
# raw_customers 0/3 0.0%
# raw_orders 0/4 0.0%
# raw_payments 0/4 0.0%
# stg_customers 1/3 33.3%
# stg_orders 2/4 50.0%
# stg_payments 2/4 50.0%
# =====================================================================
# Total 14/38 36.8%
Compare
Compares two coverage.json files generated by the compute command.
$ dbt-coverage compare coverage-after.json coverage-before.json
# Coverage delta summary
# before after +/-
# =============================================
# Coverage 62.50% 60.00% -2.50%
# =============================================
# Tables 3 4 +1/+0
# Columns 48 50 +2/+0
# =============================================
# Hits 30 30 +0/+0
# Misses 18 20 +2/+0
# =============================================
# New misses
# ==============================================================
# Catalog 15/38 (39.47%) -> 15/39 (38.46%)
# ==============================================================
# - customers 6/7 (85.71%) -> 6/8 (75.00%)
# -- new_col -/- (-) -> 0/1 (0.00%)
# ==============================================================
Combined use-case
$ cd my-dbt-project
$ dbt run # Materialize models
$ dbt docs generate # Generate catalog.json and manifest.json
$ dbt-coverage compute doc --cov-report before.json --cov-fail-under 0.5 # Fail if coverage is lower than 50%
# Make changes to the dbt project, e.g. add some columns to the DWH, document some columns, etc.
$ dbt docs generate
$ dbt-coverage compute doc --cov-report after.json --cov-fail-compare before.json # Fail if the current coverage is lower than coverage in before.json
$ dbt-coverage compare after.json before.json # Generate a detailed coverage delta report
Related packaged
https://github.com/mikaelene/dbt-test-coverage
License
Licensed under the MIT license (see LICENSE.md file for more details).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt-coverage-0.1.2.tar.gz.
File metadata
- Download URL: dbt-coverage-0.1.2.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/21.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
196948bfe07f5d931bf7d77a8fb57cf5e038cbeb8d451bb6aee60430a7dcb12d
|
|
| MD5 |
407e07aca12af2f5f3e6d2140fd9db6a
|
|
| BLAKE2b-256 |
c49d202f186553bb8bdb2a1d6bbaf8c3b1eaa7700c7c230213646d321a8726b4
|
File details
Details for the file dbt_coverage-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dbt_coverage-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/21.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ac0bb92dfc08a7443f567c47c565e90d3793cfea39270d233631858e4e5462a
|
|
| MD5 |
df4c031a9ba0679b2b9d631a17486ba5
|
|
| BLAKE2b-256 |
7b3bf52e47b3ab26f960ce4f78349ebf844e9a401ece9fde2648fa52ead2038e
|