Home

Awesome

dq-vault

This DBT package provides an overview on Data Quality for all DataVault (DV) models in your DBT project.

ci_integration_tests

dq-vault enables you to:

What does this package do?

It works by scanning your DBT test run results related to DataVault models and putting them into the following views & metrics:

What are the requirements to use this package?

A DBT project with:

Installation

packages:
  - package: infinitelambda/dq_vault
    version: [">=0.1.0", "<1.0.0"]
# dbt_project.yml
on-run-end:
  - '{{ dq_vault.store_test_results_json(results) }}'

Variables

vars:
  dq_vault__enable_store_test: true or false
  dq_vault__raw_db: 'your_custom_db or target.database'
  dq_vault__raw_schema: 'your_custom_schema or target.schema'
  dq_vault__selected_model_rules:
    - hub: ['hub']
    - sat: ['sat','satellite']
    - link: ['link','tlink','t_link','lnk','tlnk','t_lnk']
    - pit: ['pit']
    - bridge: ['bridge']
    - xts: ['xts']

In the above:

Classify the Test Type of your test cases

Currently, there are 4 built-in test types based on the test name:

Labeling test type for each test case:

models:
  - name: my_model
    tests:
      - my_test:
          test_type: duplication
models:
  - name: my_model
    tests:
      - my_test:
          meta:
            test_type: duplication

Macros

List of custom built-in macros in this package:

store_test_results_json (source, doc)

get_datavault_type (source, doc)

get_test_type (source, doc)

where_select_dv_models (source, doc)

result_to_dict (source, doc)

get_raw_test (source, doc)

create_resources (source, doc)

refresh_resouces (source, doc)

Integration Tests

The integration_tests directory contains a DBT project that tests the macros/models/etc in this dq-vault package. An integration test typically involves making 1- a new seed file; 2- a new model file; 3- a generic test to assert anticipated behavior.

For an example on integration tests, check out the tests for get_datavault_type macro:

  1. Macro definition
  2. Seed or Model file with fake data
  3. A generic test to assert the macro works as expected

Once you've added all of these files, you should be able to run:

Make sure you are currently in the integration_tests folder,

dbt deps --target {your_target}
dbt seed --target {your_target}
dbt run --target {your_target} --model {your_model_name}
dbt test --target {your_target} --model {your_model_name}

Note: You might see some Failure and Warning while running tests for models specified in integration_tests. This is a part of this package testing and is completely normal. For the current version, running dbt build inside integration_tests will yield Completed with 10 errors and 3 warnings

Alternatively, at the repo's root (/dq-vault):

chmod +x run_test.sh
./run_test.sh {your_target} {your_models}

Once all the tests are passed you're good to go! All tests will be run automatically when you create a PR against this repo.

Developer's Guide