Data Quality Updated: 2026-01-21

What is Great Expectations?

An open-source Python framework for defining, documenting, and validating data quality expectations against datasets in data pipelines.

From the field

Great Expectations (GX) is the Python-native data-testing framework that popularized the practice of "expectations as code" in data engineering. The core conceptual move is clean: instead of ad-hoc SQL checks scattered across pipelines, you declare what you expect of the data ("user_id should never be null," "status should be one of these five values," "order_total mean should be between $50 and $200") and GX validates those expectations against live data on every run. It auto-generates documentation, integrates with Airflow/Dagster/dbt/Spark, and has been in production at thousands of data teams since ~2017.

Where GX fits (and where it doesn't)

GX shines when you need: cross-source validation (same expectations across Pandas, Spark, SQL), rich expectation vocabulary (75+ built-in plus custom), auto-generated data docs, and Python integration. It's heavier than dbt tests (more setup, learning curve on the Context/DataSource/Checkpoint abstractions) and less approachable for non-engineers than YAML-based tools like Soda. For teams already deep in Python — ML pipelines, Pandas workflows, Spark jobs — GX is a natural fit. For SQL-first dbt teams, the overhead often isn't worth it; dbt's built-in tests plus a few custom ones cover 80% of the need.

Field story

A marketing-analytics client used Pandas heavily for daily campaign ROI calculations running on EMR. They'd ship a "passing" notebook to production and discover a week later that one of 40 source CSVs had added a new column that shifted their column-index-based parsing by one position — every metric was wrong for a week. Adding GX expectations as the first step in the pipeline (column order, column types, non-null ratios, value ranges for each of the 40 sources) caught the next three incidents before they reached prod. The investment was one engineer for two weeks to write expectation suites plus GitHub Actions integration. ROI paid back in the first incident. GX worked specifically because the pipeline was Python-centric — if it had been a dbt project, dbt tests would have been simpler.

Great Expectations (GX) is an open-source Python library for data testing, documentation, and profiling. It helps data teams define "expectations" about their data and validate those expectations automatically in pipelines.

Core Concepts

  1. Expectations: Assertions about data (e.g., "column A should not be null")
  2. Expectation Suites: Collections of expectations for a dataset
  3. Data Sources: Connections to your data (Pandas, Spark, SQL)
  4. Checkpoints: Validation runbooks that execute expectations
  5. Data Docs: Auto-generated documentation of expectations and results

Example Expectations

import great_expectations as gx

# Create a Data Source
context = gx.get_context()
validator = context.sources.add_pandas("my_data").read_dataframe(df)

# Define Expectations
validator.expect_column_values_to_not_be_null("user_id")
validator.expect_column_values_to_be_in_set("status", ["active", "inactive"])
validator.expect_column_mean_to_be_between("order_total", 50, 200)

Why Teams Use Great Expectations

  • Catch Issues Early: Validate data before it reaches downstream
  • Documentation: Auto-generate data quality docs
  • Collaboration: Share expectations across teams
  • Integration: Works with Airflow, dbt, Spark, and more
  • Open Source: Free to use with commercial support

Great Expectations GX Cloud

The SaaS version adds:

  • Hosted expectation management
  • Collaboration features
  • Alerting and notifications
  • Metrics and dashboards

Integration with Data Tools

  • Airflow: GX operators for pipeline validation
  • dbt: Run GX after dbt models
  • Spark: Validate large-scale data
  • Prefect/Dagster: Native integrations

Key Points

Gotchas

Great Expectations pitfalls I've hit in production:

  • The v0.x to v1.x migration is painful. GX went through a major API redesign around v0.18 → v1.0 (late 2024). Context, DataSource, and Checkpoint APIs all changed. Code from 2023 tutorials often doesn't work in 2026. When searching for help, check the version the article targets.
  • Expectation generation via profiling creates too many low-value checks. auto-profiler will generate 200 expectations on a wide table, most of which are noise (e.g., expect_column_median_to_be_between on an ID column). Prune ruthlessly to the expectations that matter; curated suites beat auto-generated ones.
  • Data Docs generation can be heavy. Rebuilding HTML docs on every run adds 10-30s. For fast-running pipelines, this matters. Configure GX to generate docs only on failure or on a separate cadence.
  • Checkpoint configs have surprising defaults. result_format=BASIC by default truncates which rows failed, making debugging harder. Set result_format=COMPLETE or at least SUMMARY in production checkpoints for useful failure details.
  • Memory pressure on large datasets. Pandas-backed expectations load entire DataFrames into memory. For datasets that don't fit, use Spark-backed or SQL-backed datasources. Teams frequently discover this at 3 AM when GX OOMs on a large nightly run.
  • expect_column_values_to_match_regex with complex patterns is slow. Regex evaluation on billions of rows is expensive. Use SQL-native pattern matching where possible; consider whether the check is actually needed or if a simpler type check covers it.
  • Expectations that pass on empty data. Most expectations return "pass" on zero rows — technically correct but misleading. Always pair with expect_table_row_count_to_be_between(min_value=1, ...) to fail-fast on empty input.
  • CI/CD integration friction with GX Cloud. GX Cloud adds a lot (dashboards, alerting) but has its own API and setup. Teams sometimes dual-run OSS + Cloud during transitions, which doubles maintenance. Pick one.
  • Python dependency conflicts with downstream stacks. GX pulls in many transitive dependencies (Pandas, SQLAlchemy, Jinja2). When added to an existing Python environment with pinned versions, conflicts are common. Consider running GX in its own virtualenv or container.

Frequently Asked Questions

What is Great Expectations used for?

Great Expectations is used for defining, validating, and documenting data quality expectations in Python-based pipelines. You write assertions about your data ("this column should not be null," "this column should contain only valid email addresses," "this column's mean should be between 50 and 200"), and GX validates those expectations against live data on every pipeline run. It also auto-generates HTML documentation of your expectations and results. Common use cases: validating Pandas DataFrames in ML pipelines, validating CSV files at ingestion, post-ETL validation of Spark outputs, and contract-style validation of data products before downstream consumption.

Is Great Expectations free?

Yes — Great Expectations Core is 100% free and open-source (Apache 2.0 license). You can self-host it at no cost. The commercial product is GX Cloud, a SaaS offering from the Great Expectations company that adds hosted expectation management, collaboration features, dashboards, alerting, and a managed validation runtime. Pricing is tier-based. Many teams run GX Core alone indefinitely; GX Cloud is worth considering when you need centralized expectation governance across many teams or advanced alerting that would take effort to build yourself.

How does Great Expectations compare to dbt tests?

dbt tests are simpler, SQL-native, and sit inside your dbt project — they cover the common cases (unique, not_null, relationships, accepted_values, plus custom SQL tests) with almost zero setup. GX is more expressive (75+ built-in expectation types vs. dbt's 4 built-ins plus custom), supports non-SQL data sources (Pandas, Spark), and auto-generates documentation, but has a steeper learning curve. For SQL-first teams on dbt, start with dbt tests; add GX only when you need expectations that dbt can't express (distribution checks, cross-column validation, non-warehouse data sources). The tools complement rather than compete.

What is an Expectation Suite?

An Expectation Suite is a named collection of expectations for a specific dataset. For example, an `orders_suite` might contain expectations like `order_id not null`, `status in (placed, shipped, cancelled)`, `total between 0 and 10000`, `created_at > 2020-01-01`. Suites are usually stored as JSON files in your project, version-controlled with the pipeline code. At validation time, GX runs the entire suite against a data batch and returns pass/fail results. Suites are the primary unit of reuse — you write a suite for a table once and run it against every new batch of that table.

How do you integrate Great Expectations with Airflow?

Use the `airflow-provider-great-expectations` package, which provides `GreatExpectationsOperator` — a task operator that runs a GX checkpoint against a dataset and fails the Airflow task if expectations fail. Typical pattern: your DAG has `extract >> gx_validate_raw >> transform >> gx_validate_transformed >> load`, so validation gates each step. Failed tasks stop the pipeline and alert on-call. For Dagster, use `dagster-great-expectations` which integrates with Dagster's asset checks. For dbt, run GX checkpoints as post-hooks or as separate tasks after `dbt run`.

What are common Great Expectations expectations?

Most-used: `expect_column_values_to_not_be_null`, `expect_column_values_to_be_unique`, `expect_column_values_to_be_in_set` (allowed values), `expect_column_values_to_match_regex`, `expect_table_row_count_to_be_between`, `expect_column_mean_to_be_between`, `expect_column_value_lengths_to_be_between`. Distribution checks: `expect_column_kl_divergence_to_be_less_than` (useful for drift detection). Cross-column: `expect_column_pair_values_a_to_be_greater_than_b`. Custom expectations can be written in Python for domain-specific rules. Most teams use ~10-15 expectation types regularly; the other 60+ cover edge cases.

Should I use Great Expectations or Soda?

Depends on team profile. GX is Python-centric, code-first, highly expressive — better for ML pipelines and teams comfortable with Python. Soda is YAML-centric with SodaCL, deliberately simpler, accessible to analysts and non-engineers — better for SQL-first teams and organizations where non-engineers need to define checks. Both run on Snowflake/BigQuery/Postgres and integrate with orchestrators. Feature-wise they overlap 70%; the decision usually comes down to whether your team prefers Python or YAML as the check-definition language. Some teams use both — Soda for analyst-defined business checks, GX for engineering-defined structural validation.

Related Terms

Data Qualitydbt (Data Build Tool)Data Observability

Related Tools

dbtSodaMonte CarloApache AirflowPandas

Learn More

Browse All Terms Read Articles