expect_column_values_to_be_in_type_list
How it Works
The expect_column_values_to_be_in_type_list test from the dbt-expectations package validates that a column's data type is one of a specified list of acceptable types. Unlike expect_column_values_to_be_of_type (which requires an exact match), this test allows multiple compatible types — useful for handling database-specific type variants.
Steps and Conditions
- Column Selection: Identify the column to evaluate.
- Define Type List: Provide the list of acceptable types using
column_type_list. - Execution: The actual column type is retrieved from metadata and checked against the list.
- Outcome: Pass if the type is in the list; fail if it is not.
Example Usage: Cross-platform Analytics
A team running models across BigQuery and Snowflake wants to ensure their amount column is always a numeric type, but the exact type name differs between platforms.
models:
- name: payments
columns:
- name: amount
tests:
- dbt_expectations.expect_column_values_to_be_in_type_list:
column_type_list: ["numeric", "float64", "number", "decimal"]This ensures the column is always numeric regardless of which database platform is running the model.
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.