not_constant
How it Works
The not_constant test from dbt-utils™ validates that a column contains more than one distinct value. A column that is fully constant — where every row has the same value — is often a sign of a broken join, a hardcoded default, or an error in the transformation logic.
Steps and Conditions
- Column Selection: Identify the column to validate.
- Execution: The number of distinct values is computed.
- Outcome: Pass if more than one distinct value exists; fail if the column is entirely uniform.
Example Usage: Event Tracking
An event tracking model should contain multiple distinct event types. If every row has the same event_type, it likely means a filter was accidentally hardcoded.
models:
- name: user_events
columns:
- name: event_type
tests:
- dbt_utils.not_constantA constant event_type column would indicate only one type of event is being captured, which would severely limit the usefulness of the model for analytics.
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.