Great Expectations (GX Core)

repository·develop·Indexed 11 days ago

https://github.com/fivetran/great_expectations

A data quality framework that uses 'Expectations'—expressive and extensible unit tests for data—to help teams validate data, generate documentation, and preserve institutional knowledge. This documentation includes setup guides for MSSQL, SingleStoreDB, and Spark testing environments, as well as integration with DataProfiler for automated statistics and entity recognition (PII/NPI) across structured and unstructured data formats.

Tokens
89.2K
Snippets
231
Records
426
Agent score
95%

What's inside Great Expectations

  1. Trigger actions based on Validation Results using Checkpoints

    develop

    You can automate responses to data validation outcomes by using Checkpoints. Checkpoints allow you to define a suite of expectations and then trigger specific actions—such as sending alerts or updating Data Docs—based on the resulting ValidationResult.

    Key workflows include:

    • Creating a Checkpoint with Actions: Configuring a Checkpoint to execute specific tasks when validation succeeds or fails.
    • Creating custom Actions: Defining your own logic to run in response to validation results.
    • Choosing a Result Format: Configuring how much detail (verbosity) is included in the returned ValidationResult.
    • Running a Checkpoint: Executing the validation process to trigger the configured automation.
  2. Ways to customize Expectations

    develop

    Great Expectations allows you to add domain-specific knowledge and precise evaluation criteria to your data validations through several customization methods:

    • Restrict an Expectation to specific rows: Filter your data so that only a subset of rows are validated for a given Expectation.
    • Define a custom Expectation class: Subclass an existing Expectation to add additional notes, metadata, or default attributes.
    • Use SQL to define a custom Expectation: Create an Expectation that evaluates the results of a customized SQL query.
    • Define a Multi-source Expectation: Create an Expectation that queries multiple Data Sources and compares their results for equality.
  3. Data quality use cases in GX Core

    develop

    GX Core enables you to define and validate data quality checks across several key dimensions. You can use GX to address the following data quality and observability scenarios:

    • Distribution: Validate that data values adhere to expected ranges.
    • Freshness: Verify that data is available within expected timeframes.
    • Integrity: Validate relationships and dependencies between data.
    • Missingness: Identify gaps in data to maintain data completeness.
    • Schema: Verify that data structure conforms to established rules.
    • Uniqueness: Validate that distinct values are present only once.
    • Volume: Validate that record quantity falls within expected bounds.
    • Unstructured data: Validate structured metadata generated from unstructured content.
  4. Connect to different data sources in Great Expectations

    develop

    Great Expectations (GX) allows you to connect to various data sources and organize that data into Batches for validation. You can connect to data through three primary methods:

    • SQL Data: Connect to data residing in SQL databases and organize it into Batches.
    • Filesystem Data: Connect to data stored as files within a folder hierarchy and organize it into Batches.
    • Dataframes: Connect to data held in memory using pandas or Spark Dataframes and organize it into Batches.
  5. Configure project settings in Great Expectations

    develop

    Great Expectations (GX) project settings allow you to manage advanced configurations including metadata storage, Data Docs hosting, credential security, and analytics.

    Key configuration areas include:

    • Metadata Stores: Define where GX saves Expectation Suite configurations, Checkpoint Configurations, and Validation Results.
    • Data Docs: Configure the content and hosting locations for your Data Docs sites.
    • Credentials: Securely store and access credentials for database connection strings and tokens for Checkpoint Actions.
    • Secrets Managers: Integrate with AWS Secrets Manager, Google Cloud Secret Manager, or Azure Key Vault to retrieve credentials securely.
    • Analytics Events: Control whether GX collects internal analytics events.
  6. Validate data distribution with GX

    develop

    Data distribution analysis focuses on the spread, shape, and characteristics of data. Validating distribution is critical for ensuring statistical validity for ML models, detecting anomalies/outliers, maintaining data consistency over time, and performing quality control to detect corruption or system errors.

    Key aspects to validate include:

    • Shape: Using metrics like KL divergence.
    • Center: Using metrics like Mean or Median.
    • Spread: Using metrics like Standard Deviation or Quantiles.
    • Bounds: Using range checks on individual values or summary statistics.
  7. Explore Great Expectations learning resources

    develop

    The Great Expectations (GX) documentation provides several learning paths to help you master data quality management:

    • GX in your data pipeline: Guidance on where to integrate GX within your existing data workflows to monitor and manage data quality.
    • Data quality use cases: Practical scenarios and how to apply GX to address specific data quality challenges.
    • Integration tutorials: Step-by-step instructions for integrating GX with other tools in your stack.
    • Glossary: A comprehensive alphabetical list of GX-specific terms and definitions to help you understand the core vocabulary.
  8. Use Great Expectations Geospatial Expectations to validate geospatial data

    develop
    The great_expectations_geospatial_expectations package provides a collection of Great Expectations (GX) Expectations specifically designed to validate geospatial data. This is useful for ensuring the integrity of datasets containing location information (coordinates), attribute information, and temporal information before they are used for maps, graphs, or cartograms.
  9. Manage missing data with GX Expectations

    develop
    Great Expectations (GX) provides a suite of Expectations to detect and manage 'missingness' (the presence of NULL values). You can use these to ensure critical fields are populated, monitor for unexpected nulls, or validate that certain fields remain empty as expected. Integrating these into your data pipelines allows you to catch data integrity issues early in the lifecycle.
  10. Use great_expectations_contrib for package development

    develop

    The great_expectations_contrib tool provides a workflow for managing the lifecycle of contributor packages. Its primary functions are:

    • Project Initialization: Creates the standard project structure using a template.
    • Completeness Checks: Performs automated checks to ensure your contribution meets the required standards before submission.
    • PyPi Upload: Facilitates uploading finished packages to PyPi (requires a pre-existing PyPi account).
  11. What is a Data Context in Great Expectations

    develop

    A Data Context is the central hub for all Great Expectations (GX) operations. It defines the storage location for your metadata, including:

    • Configurations: Data Sources, Expectation Suites, Checkpoints, and Data Docs.
    • Validation Results: The outcomes of your data validations and their associated metrics.

    Every script that utilizes GX Core should begin by creating a Data Context to provide access to these objects and helper functions.

  12. What is a Validation Definition

    develop

    A ValidationDefinition is a fixed reference that links a specific Batch of data to an Expectation Suite.

    It serves two primary purposes:

    1. Standalone Validation: It can be run independently to validate a specific batch of data against its associated expectations, which is useful for testing or data exploration.
    2. Checkpoint Integration: Multiple ValidationDefinition instances can be passed to a Checkpoint. When the Checkpoint runs, it executes defined Actions based on the validation results for each provided definition.