Migrate dbt tests to AnomalyArmor

Keep dbt tests where they belong: in your pipeline. Add AnomalyArmor on top for continuous warehouse monitoring, and bring your schema.yml assertions with you via ODCS.

What the recipe does

The community dbt-odcs package walks every resource file in your dbt project, reads schema.yml test entries, and emits a single ODCS v3.1.0 YAML document. Paste the output into /migrate/soda (the shared ODCS entry point) and every rule applies against your tables after signup.

  • not_null → ODCS not_null
  • unique → ODCS unique
  • accepted_values → ODCS in_set
  • relationships → ODCS foreign_key
  • Generic tests (custom macros) → flagged for manual review

Install

The dbt-odcs package is open source and maintained by the ODCS community.

shell
pip install dbt-odcs

The recipe

Save as dbt_to_odcs.py in your dbt project root and pipe the output to a YAML file.

dbt_to_odcs.py
# Translate dbt schema.yml tests to ODCS YAML via the dbt-odcs package.
# Run from your dbt project root.
from dbt_odcs import compile_to_odcs
import yaml

# Pass your dbt project path; compile_to_odcs loads schema.yml entries
# across all resource files and returns a dict in ODCS v3.1.0 shape.
odcs = compile_to_odcs(
    project_dir=".",
    profiles_dir="~/.dbt",
    contract_name="my_warehouse",
)

print(yaml.safe_dump(odcs, sort_keys=False))

Then run: python dbt_to_odcs.py > contract.yaml and paste the resulting YAML into /migrate/soda.

What does not translate automatically

Singular tests and custom test macros (anything outside the four built-in generic tests) do not translate to ODCS. The recipe flags them in stderr so you can decide whether to rewrite them as custom SQL rules in ODCS, keep them in dbt, or drop them. Most teams keep their custom dbt tests where they are and add AnomalyArmor on top.

Run the recipe

dbt migration

Frequently Asked Questions

Not yet. The translation from Expectation Suites JSON to ODCS YAML is a short Python recipe, published on this page. Most teams copy the recipe, run it locally against their GE context, and paste the resulting YAML into /migrate/soda (which is the shared ODCS entry point). A native importer is on the roadmap.