Write dbt unit tests to validate SQL transformation logic without running against warehouse data

domain: docs.getdbt.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a unit_tests block in the model's YAML file or in a dedicated _unit_tests.yml file
  2. Define input fixture data inline using the rows format for each model reference that the model under test depends on
  3. Define the expected output rows in the expect block
  4. Run dbt test --select model_name to execute only the unit tests for that model; observe that dbt creates an ephemeral CTE from the fixtures and compares the model output to the expectation
  5. Add edge-case fixtures for NULL inputs, empty inputs, and boundary date values to ensure the transformation handles them correctly

Known gotchas

Related routes

Write dbt unit tests to validate SQL transformation logic without hitting the warehouse for real data
data-engineering · 5 steps · unrated
Write a dbt Python model that runs on Snowpark, Databricks, or BigQuery for logic that's awkward in SQL
docs.getdbt.com · 5 steps · unrated
Write bulkified Apex trigger logic that processes up to 200 records per transaction without hitting SOQL or DML governor limits
developer.salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans