expect_table_columns_to_not_contain_set
How it Works
The expect_table_columns_to_not_contain_set test from the dbt-expectations package verifies that none of the columns in a specified list are present in the model. This is the inverse of expect_table_columns_to_contain_set and is useful for ensuring that deprecated columns, PII fields, or columns that should have been dropped are no longer part of a model's schema.
An optional transform argument (e.g., lower) enables case-insensitive comparison.
Steps and Conditions
- Define Disallowed Columns: List the column names that must NOT be present.
- Optional Transform: Apply a transform for case-insensitive matching.
- Verification: Each disallowed column is checked against the actual schema.
- Outcome: Pass if none of the disallowed columns exist; fail if any are found.
Example Usage: GDPR Compliance
A GDPR compliance team wants to ensure that personally identifiable fields like full_name and date_of_birth have been removed from a reporting-layer model.
models:
- name: reporting_customers
tests:
- dbt_expectations.expect_table_columns_to_not_contain_set:
column_list: ["full_name", "date_of_birth", "ssn"]
transform: lowerIf any of these PII columns remain in the reporting model, the test fails and blocks the deployment.
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.