Using a single expectation across multiple tables

Just getting started with GE and looking for some guidance…

I have a use case for an expectation that a string column should not contain any uppercase characters.
What would be the best practice or typical workflow for applying this expectation against ~150 specific columns across ~50 tables.

So far I’ve been able to do this on a single column using this pattern, but curious how to efficiently scale this across many different schemas/tables

batch.expect_column_values_to_not_match_regex(column = '[my_column]',
                                             regex = '[A-Z]+')
1 Like

The 0.13.0 release introduced a feature that addresses this need - Parametrized Expectations. It allows a user to implement a new Expectation by extending an existing one and applying some constraints on its parameters.

In your case it would mean creating a new expectation called something like expect_column_values_to_not_contain_uppercase_characters by extending the expect_column_values_to_not_match_regex expectation and locking the regex parameter to '[A-Z]+'

This how-to guide shows the exact steps: https://docs.greatexpectations.io/en/latest/guides/how_to_guides/creating_and_editing_expectations/how_to_create_parameterized_expectations_super_fast.html