accepted_values
How it Works
The accepted_values test is one of dbt™'s four built-in generic tests. It validates that every value in a column belongs to a predefined list of acceptable values. This is ideal for categorical columns like status codes, types, or classifications where the full value space is known and controlled.
The quote argument (default true) controls whether values are treated as strings.
Steps and Conditions
- Column Selection: Choose the column to validate.
- Define Allowed Values: List acceptable values using the
valuesargument. - Execution: Every row is checked against the allowed list.
- Outcome: Pass if all values are in the list; fail if any unlisted values appear.
Example Usage: Order Management
An order management system uses a fixed set of statuses. The team wants to ensure no unrecognized codes enter the system.
models:
- name: orders
columns:
- name: status
tests:
- accepted_values:
values: ['placed', 'processing', 'fulfilled', 'returned', 'cancelled']Any order carrying an unrecognized status code will fail the test, protecting downstream logic that depends on these values.
Interested to Learn More? Try Out the Free 14-Days Trial
One AI-native workspace to build, ship, and monitor dbt™ — without the tool sprawl.
Join industry leaders winning with DinoAI agents
Data engineers and analysts at the most AI-native startups and enterprises use Paradime's DinoAI agents everyday to become market leaders.