expect_column_values_to_have_consistent_casing
How it Works
The expect_column_values_to_have_consistent_casing test from the dbt-expectations package checks that all string values in a column use the same casing convention — either all uppercase, all lowercase, or title case. This is important for preventing silent join failures or grouping errors that occur when 'Active' and 'active' are treated as distinct values.
Steps and Conditions
- Column Selection: Identify the string column to evaluate.
- Execution: The test checks all non-null values to see if they share a consistent casing pattern.
- Outcome: Pass if all values use consistent casing; fail if mixed casing is detected.
Example Usage: Subscription Platform
A subscription platform stores plan tiers as strings. The team wants to catch any casing inconsistencies before they cause issues in downstream reporting.
models:
- name: subscriptions
columns:
- name: plan_tier
tests:
- dbt_expectations.expect_column_values_to_have_consistent_casingIf plan_tier contains both 'Premium' and 'premium', the test will fail and prompt the team to standardize the values upstream.
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.