expect_column_values_to_match_like_pattern_list
How it Works
The expect_column_values_to_match_like_pattern_list test from the dbt-expectations package validates that column values match at least one SQL LIKE pattern from a provided list. The match_on argument controls whether values need to satisfy any (default) or all patterns in the list.
Steps and Conditions
- Column Selection: Identify the column to validate.
- Define Pattern List: Provide the list of LIKE patterns.
- Match Mode: Set
match_ontoanyorall. - Execution: Each value is tested against the pattern list.
- Outcome: Pass if values satisfy the match condition; fail otherwise.
Example Usage: Product SKUs
A retail company accepts product SKUs in multiple regional formats — either starting with a region prefix or following a global format.
models:
- name: product_inventory
columns:
- name: sku
tests:
- dbt_expectations.expect_column_values_to_match_like_pattern_list:
like_pattern_list: ["US-%", "EU-%", "GLOB-%"]
match_on: anyAny SKU that doesn't start with a recognized region prefix fails the test, catching malformed entries before they reach inventory systems.
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.