expect_table_columns_to_contain_set
Feb 24, 2026
·
5
min read
Schema
·
dbt-expectations
·
Model,Seed,Source
How it Works
The expect_table_columns_to_contain_set test from the dbt-expectations package checks that a model, seed, or source contains all columns from a predefined list. Unlike stricter schema tests, this test does not fail if the table has additional columns beyond those specified — it only validates that the required ones are present. An optional transform argument (e.g., lower) can be applied to normalize column name casing before comparison.
Steps and Conditions
Define Required Columns: List the column names that must be present.
Optional Transform: Apply a transform like
lowerfor case-insensitive matching.Verification: Each required column is checked against the actual schema.
Outcome: Pass if all listed columns exist; fail if any are missing.
Example Usage: Logistics Platform
A logistics platform needs to ensure its shipments source table always contains the core fields needed for downstream reporting, regardless of any extra columns the upstream team may add.
This guards against upstream schema changes that might silently drop critical fields, protecting downstream models from breaking unexpectedly.





