Great Expectations (Data Quality) Cheat Sheet
Define, validate, and document data quality expectations for pipelines using Great Expectations suites, checkpoints, and data docs.
2 PagesIntermediateJan 20, 2026
Create an Expectation Suite
Define reusable data quality rules against a pandas or SQL data source.
python
import great_expectations as gxcontext = gx.get_context()source = context.sources.add_pandas("orders_source")asset = source.add_dataframe_asset(name="orders", dataframe=df)validator = context.get_validator( batch_request=asset.build_batch_request(), expectation_suite_name="orders_suite",)validator.expect_column_values_to_not_be_null("order_id")validator.expect_column_values_to_be_between("amount", min_value=0, max_value=100000)validator.expect_column_values_to_be_in_set("status", ["pending", "completed", "cancelled"])validator.save_expectation_suite(discard_failed_expectations=False)
Run a Checkpoint
Bundle a batch and a suite into a checkpoint and execute validation as a pipeline step.
python
checkpoint = context.add_or_update_checkpoint( name="orders_checkpoint", validations=[{ "batch_request": asset.build_batch_request(), "expectation_suite_name": "orders_suite", }],)result = checkpoint.run()print(result.success) # False if any expectation failedif not result.success: raise ValueError("Data quality check failed — halting pipeline")
Validate a SQL Table
Point Great Expectations at a warehouse table via a SQLAlchemy connection string.
python
source = context.sources.add_sql( name="warehouse", connection_string="postgresql://user:pass@host/db")asset = source.add_table_asset(name="orders_tbl", table_name="orders")validator = context.get_validator( batch_request=asset.build_batch_request(), expectation_suite_name="orders_suite",)validator.expect_table_row_count_to_be_between(min_value=1)
Frequently Used Expectations
A starting set of expectation methods covering the majority of data quality checks.
- expect_column_values_to_not_be_null- flags unexpected nulls in a required column
- expect_column_values_to_be_unique- enforces primary-key-like uniqueness
- expect_column_values_to_be_between- range check for numeric columns
- expect_column_values_to_match_regex- format validation, e.g. emails or phone numbers
- expect_table_row_count_to_be_between- guards against empty or unexpectedly small loads
- expect_column_pair_values_A_to_be_greater_than_B- cross-column consistency checks
Pro Tip
Wire checkpoint.run() into your orchestrator (Airflow, Dagster) as a hard gate before the load step — catching a schema drift or null spike before it reaches the warehouse is far cheaper than debugging a downstream dashboard.
Was this cheat sheet helpful?
Explore Topics
#GreatExpectationsDataQuality#GreatExpectationsDataQualityCheatSheet#DataScience#Intermediate#CreateAnExpectationSuite#RunACheckpoint#ValidateASQLTable#FrequentlyUsedExpectations#MachineLearning#DevOps#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance