Skip to main content

Verified data quality,
with a report for every validation.

Great Expectations declares data quality rules as expectations and checks them against SQL databases, files, and pandas and Spark DataFrames. Every validation returns a result and human-readable documentation. Follow a validation, from the connection to the data to the Data Docs.

This feature is only available starting from version 2.3.

Great Expectations (GX) is a Python data validation library: rules are written as expectations, and every validation returns a result and human-readable documentation.

Expectations are grouped into an Expectation Suite, and the Checkpoint is the primary means of validating data in production.

Rules

One expectation per rule

Each rule is an Expectation, a verifiable assertion about the data, and Expectations are grouped into an Expectation Suite.

Validation

From the batch of data to the result

The Validation Definition links a batch of data to a suite, the Checkpoint runs it, and GX returns a Validation Result.

Report

Readable documentation

Data Docs translate expectations and results into human-readable documentation, as static web pages.

On this page

See a validation happen​

Press Play or step through one at a time. Underlined names lead to the Glossary.

DataWhat will be validated
Data SourceRepresents the data store
Data AssetCollection of records
Batch DefinitionOrganizes records into batches
RulesWhat is expected of the data
ExpectationA verifiable rule
Expectation SuiteGroups the Expectations
ExecutionWho validates and reacts
Validation DefinitionLinks the batch to the suite
CheckpointRuns the validation
ActionsReact to the result
ResultsWhat the validation leaves behind
Validation ResultWhat GX returns
Data DocsReadable documentation
Step 1 of 7

1 GX knows the data

The Data Source is the GX representation of a data store: a SQL database, files in a folder hierarchy, or pandas and Spark DataFrames. Within it, the Data Asset groups the records that will be validated.

  1. GX knows the data. The Data Source is the GX representation of a data store: a SQL database, files in a folder hierarchy, or pandas and Spark DataFrames. Within it, the Data Asset groups the records that will be validated.
  2. Records become batches. The Batch Definition tells GX how to organize the records in the Data Asset. Each batch, a Batch, is a selection of records from the Data Asset.
  3. Rules are expectations. An Expectation is a verifiable assertion about data. Expectations are grouped into an Expectation Suite, which describes the ideal state of a set of data.
  4. The Validation Definition joins data and rules. The Validation Definition explicitly associates the Batch Definition with the Expectation Suite. It can be run with the predefined defaults or with parameters provided at runtime.
  5. The Checkpoint runs the validation. The Checkpoint runs one or more Validation Definitions. It is the primary means of validating data in a production deployment of GX.
  6. The validation result. After validating the data against the suite, GX returns a Validation Result.
  7. Actions react to the result. Based on the Validation Results, the Checkpoint runs a set of Actions, such as the SlackNotificationAction, which sends a Slack message when an Expectation fails, and the UpdateDataDocsAction, which updates the Data Docs site with the results.
Figure 1 - A validation in Great Expectations. Data arrives as a batch, expectations form the suite, the Validation Definition associates them, the Checkpoint runs it, and the result feeds the Actions and the Data Docs.

Architecture​

Data and expectations meet in the Validation Definition. The Checkpoint runs it and delivers the result.

Great Expectations architecture: data, expectations, Checkpoint, and resultsThe Data Source gives access to the data, and the Data Asset groups the records. The Batch Definition organizes the records into batches. A Validation Definition associates the Batch Definition with an Expectation Suite, which groups Expectations. The Checkpoint runs the Validation Definition, produces the Validation Result, and triggers Actions, which update the Data Docs.DataData SourceData AssetBatch DefinitionExpectation SuiteExpectationExpectationValidation DefinitionCheckpointActionsResultsData DocsValidation Result
Figure 2 - Great Expectations architecture: from the data to the Validation Definition, the Checkpoint, and the results. Underlined terms lead to the Glossary.

What the figure shows:

  1. The Data Source: provides access to the data.
  2. The Data Asset: groups the records.
  3. The Batch Definition: organizes the records into batches.
  4. The Expectation Suite: groups the Expectations.
  5. The Validation Definition: associates the Batch Definition with the Expectation Suite.
  6. The Checkpoint: runs the Validation Definition.
  7. The Validation Result: is the outcome of the validation, returned by GX.
  8. The Actions: those of the Checkpoint react to the result.
  9. The Data Docs: readable documentation, updated by the Checkpoint Actions.

The Data Context is the Python object that provides access to the configurations, metadata, and actions of this workflow.

From data to batch​

A data store, from the broadest level to the most concrete: each level contains the next.

Level 1 of 3

Data Source

The GX representation of a data store. The data in a Data Source is organized into batches for validation.

  • SQLData in SQL databases.
  • FilesystemData stored as files in a folder hierarchy.
  • DataframesData in pandas or Spark DataFrames.
  1. Data Source. The GX representation of a data store. The data in a Data Source is organized into batches for validation.
    • SQL. Data in SQL databases.
    • Filesystem. Data stored as files in a folder hierarchy.
    • Dataframes. Data in pandas or Spark DataFrames.
  2. Data Asset. A collection of records within the Data Source, usually named after the underlying data system.
  3. Batch Definition. Tells GX how to organize the records in the Data Asset. Each batch, a Batch, is a selection of records from the Data Asset.
    • Validation Definition. Associates the Batch Definition with an Expectation Suite.
Figure 3 - The data levels in Great Expectations. The terms beside each level accompany that level.

What a validation produces​

The result, the documentation, and the reactions: three outputs of every Checkpoint run.

Result

Validation Result

Returned by GX after the data is validated against an Expectation or an Expectation Suite. It is what the Actions and the Data Docs receive.

Documentation

Data Docs

Human-readable documentation generated from the Expectations, the Validation Results, and other metadata, as static web pages. The UpdateDataDocsAction, in a Checkpoint, updates the site on every run.

Reaction

Actions

In a Checkpoint, Actions such as the SlackNotificationAction send notifications when an Expectation fails, and custom Actions are possible. The list of Actions runs once for each Validation Definition in the Checkpoint, and notify_on controls when a notification is triggered.

Why Great Expectations​

Declarative rules

Expectations

Each rule is a verifiable assertion about the data, and the rules are grouped into suites that describe the ideal state of a set of data.

Multiple sources

SQL, files, and DataFrames

SQL databases, files in a folder hierarchy, and pandas and Spark DataFrames are organized into batches for validation.

Readable reports

Data Docs

Human-readable documentation, as static web pages, compiled automatically from the data tests.

Production

Checkpoint

The primary means of validating data in a production deployment of GX, with one or more Validation Definitions.

Reaction to the result

Actions

Notifications, such as a Slack message when an Expectation fails, Data Docs updates, and custom Actions.

At runtime

Runtime parameters

A Validation Definition runs with the predefined defaults or with parameters provided at runtime.

In the TDP editions​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter1.3.5TDP Datacenter components
TDP Kubernetes1.23.0

In TDP Datacenter​

In TDP Datacenter, Great Expectations is the GREAT_EXPECTATIONS service, installed and managed by Ambari as a Python library.

Service components

GREAT_EXPECTATIONS_CLIENT (client, one or more). Component category.

With Spark

The spark3-env configuration of Spark uses the Great Expectations python3 and ipython3 in PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON when GX is installed on the machine.

With Airflow

The airflow-provider-great-expectations provider already comes installed in Airflow.

With JupyterLab

The great-expectations library is available in the JupyterLab notebooks.

In TDP Kubernetes​

In TDP Kubernetes, Great Expectations is a Python library installed in the Spark and Jupyter images.

In the images

The Spark image and the Jupyter image include Great Expectations, along with Polars, DuckDB, and PyIceberg. The versions are in TDP Kubernetes Components.

In the notebooks

The library is available in the JupyterLab notebooks, installed by the Jupyter image.

In Spark applications

The library is available in Spark applications, installed by the Spark image.

In both editions, the flow of a validation is the one in Figure 1. What changes is where the library is installed: on the cluster machines in TDP Datacenter, and in the Spark and Jupyter images in TDP Kubernetes.

Next steps​

Sources​

Great Expectations - Documentation

GX Core - Introduction

GX Core - Overview

Great Expectations