not_empty_string
How it Works
The not_empty_string test from dbt-utils™ validates that a column contains no empty string values (''). This is a common complement to not_null — many systems store empty strings instead of nulls, which can silently break string operations, lookups, or email-sending logic.
An optional trim_whitespace argument (default true) strips whitespace before the empty check, catching values like ' ' that would otherwise pass.
Steps and Conditions
- Column Selection: Identify the string column to validate.
- Trim Setting: Configure
trim_whitespaceto control whitespace handling. - Execution: Each value is checked for emptiness after optional trimming.
- Outcome: Pass if no empty strings are found; fail if any are present.
Example Usage: Email Marketing
An email marketing platform requires that all subscriber email addresses are non-empty strings, not just non-null.
models:
- name: subscribers
columns:
- name: email_address
tests:
- dbt_utils.not_empty_string:
trim_whitespace: trueEmpty or whitespace-only email addresses would cause mailing failures, so this test prevents them from reaching the email send queue.
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.