Skip to main content

Run your dbt tests using Great Expectations as the execution engine

Project description

dbt-gx

PyPI Python CI License: MIT

Run your dbt tests powered by Great Expectations — richer assertions, structured JSON results, and auto-generated data docs, without changing a single line of your dbt project.

dbt-gx bridges dbt and Great Expectations. It reads your compiled dbt manifest, converts your existing tests into GX expectations, executes them against your warehouse, and writes machine-readable results you can feed into dashboards, alerts, or CI gates.

Why dbt-gx?

  • Zero setup overhead — no separate GX project, no config files to maintain; point it at your dbt project and go
  • Drop-in compatibilitynot_null, unique, and popular dbt_utils tests convert automatically with no changes to your models
  • Structured output — JSON results per suite and per expectation, ready for downstream processing or CI failure thresholds
  • Fully extensible — map any GX expectation with a one-line YAML entry, or plug in a custom Python function for logic that goes beyond simple checks
  • Optional data docs — generate a browsable HTML validation report alongside your dbt docs

Installation

# Install core package (PostgreSQL support included)
pip install dbt-gx

# With Snowflake support
pip install "dbt-gx[snowflake]"

After installation, the dbt-gx command is available in your shell:

dbt-gx --help

Usage

CLI Usage

  1. Add configuration to your dbt project:

Create a dbt_gx_config.yml file in your dbt project root:

project_dir: .
profiles_dir: ~/.dbt
target: dev
vars: {}
  1. (Optional) Create a custom test conversion configuration file:

The package comes with built-in test conversions for common dbt tests. If you need to add or override test conversions, create a test_mappings.yml file:

test_mappings:
  # Override a default test conversion
  unique:
    expectation: expect_column_values_to_be_unique
    params:
      column: "{column_name}"
      ignore_null: true  # Add additional parameter

  # Add a custom test conversion
  custom_test:
    expectation: custom_expectation
    params:
      column: "{column_name}"
    function: path.to.custom_function
  1. Run tests:
# Use only default test conversions
dbt-gx test --config dbt_gx_config.yml

# Use default test conversions and your custom ones
dbt-gx test --config dbt_gx_config.yml --test-conversion-config test_mappings.yml

Configuration

Built-in Test Conversions

The package includes default test conversions for:

  • Standard dbt tests:

    • unique
    • not_null
    • accepted_values
    • relationships
  • dbt_utils tests:

    • dbt_utils.at_least_one
    • dbt_utils.equal_rowcount
    • dbt_utils.fewer_rows_than
    • dbt_utils.not_constant
  • dbt_expectations tests:

    • dbt_expectations.expect_column_values_to_be_between
    • dbt_expectations.expect_column_values_to_match_regex
    • dbt_expectations.expect_column_values_to_be_in_type_list

Custom Test Conversions

You can override default test conversions or add new ones in your custom configuration file. Each test configuration can include:

  • expectation: The Great Expectations expectation name
  • params: Parameters to pass to the expectation
  • function: (Optional) Path to a custom conversion function

Custom Test Functions

You can create custom test conversion functions:

def custom_function(test_config: dict, context: dict) -> dict:
    """
    Custom test conversion function.

    Args:
        test_config: The dbt test configuration
        context: Context information including column name, table name, etc.

    Returns:
        dict: Great Expectations expectation configuration
    """
    return {
        "expectation_type": "custom_expectation",
        "kwargs": {
            "column": context["column_name"],
            # Add custom parameters
        }
    }

Supported databases

Database Install extra
PostgreSQL (included)
Snowflake dbt-gx[snowflake]

Development

pip install -e ".[dev]"
pre-commit install

Unit tests (no external services)

pytest tests/test_scanner.py tests/test_converter.py tests/test_config.py tests/test_runner.py

Integration tests (requires Docker)

Start the Postgres database (exposed on port 5433), compile the test dbt project, then run dbt-gx against it:

docker compose up -d

cd tests/resources/dbt_projects/jaffle-shop
dbt deps
dbt seed --profiles-dir ../../dbt_profiles --target dev
dbt run  --profiles-dir ../../dbt_profiles --target dev
cd ../../../..

dbt-gx --project-dir tests/resources/dbt_projects/jaffle-shop \
  test \
  --profiles-dir tests/resources/dbt_profiles \
  --target dev

Results are written to tests/resources/dbt_projects/jaffle-shop/target/dbt_gx/test_results.json.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_gx-0.1.0.tar.gz (51.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_gx-0.1.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file dbt_gx-0.1.0.tar.gz.

File metadata

  • Download URL: dbt_gx-0.1.0.tar.gz
  • Upload date:
  • Size: 51.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dbt_gx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e2cbc33a2f12b819bf9a0bf65e18553e9eb0b6d0b4bfa28a4fdb48a5f3be13c
MD5 bcccbf0a3b570b378db31ee192509281
BLAKE2b-256 202d92468fc4e04393ac3fd460852f46e921c9a03baeab288daae2800da34bb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_gx-0.1.0.tar.gz:

Publisher: release.yml on ms32035/dbt-gx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbt_gx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dbt_gx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dbt_gx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ffd1ee6b8fd6fded6ff62bbbdddb42cde43e0a3f580fd1ba8f30c2ead98724e
MD5 b9165280dd3e0223b85d3f27d7f75045
BLAKE2b-256 3ac09161036a3eef5060eed266e47c68a572841f9c165dbb1f78aa970c848196

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbt_gx-0.1.0-py3-none-any.whl:

Publisher: release.yml on ms32035/dbt-gx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page