dbt · Testing & Documentation

Test severity: error vs warn

Mediumseveritywarnerrortestsci

Interview question

What do test severity levels error and warn mean in dbt?

How to answer

The short answer

Test severity controls whether a failing test fails the dbt invocation or only warns.

error (default)

If the test finds failing rows, dbt marks the test as failed and the CLI exits non-zero (depending on flags / build behavior). Use for hard contracts: , critical FKs, amounts that must never be null.

warn

Failures show up as warnings but do not necessarily fail the whole job. Useful for:

  • Newly added tests while cleaning historical bad data
  • Soft (e.g. "prefer unique emails, but legacy dupes exist")
  • Monitoring drift before enforcing a hard gate
YAML
columns:
  - name: email
    tests:
      - unique:
          config:
            severity: warn

Mental model

You may also see store_failures, where filters on tests, and warn_if / error_if style thresholds on some tests/packages to tolerate small failure counts.

Interview tip: "Start new quality rules as warn while remediating data, then flip to error once the warehouse is clean so CI protects the contract."

How severity behaves in dbt build

An error test that fails stops the models after it from running. A warn test that fails is reported but does not skip anything, so a rule you set to warn never blocks the pipeline by itself.

You can also set thresholds, so one bad row does not break a large table:

YAML
columns:
  - name: order_id
    tests:
      - not_null:
          config:
            severity: error
            warn_if: ">0"
            error_if: ">100"

Here any failing row is a warning, and more than 100 failing rows is an error. This is a good way to introduce a rule on messy history: start with a wide error_if, watch the count fall, then tighten it to zero.