unique
How it Works
The unique test is one of dbt™'s four built-in generic tests. It validates that a column contains no duplicate non-null values. This is the most fundamental uniqueness constraint in dbt™ and is typically applied to primary key columns to enforce entity integrity.
Steps and Conditions
- Column Selection: Identify the column to validate.
- Execution: All non-null values are checked for duplicates.
- Outcome: Pass if all non-null values are unique; fail if duplicates exist.
Example Usage: User Table
A user management model should have a unique user_id for every record.
models:
- name: users
columns:
- name: user_id
tests:
- uniqueDuplicate user IDs would cause broken joins, inflated metrics, and incorrect downstream reporting, making this one of the most critical tests to apply on any primary key.
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.