how-to-guides

No menu items for this category
OpenMetadata Documentation

Data Quality as Code

Data Quality as Code enables you to programmatically build, run, and manage data quality tests within your ETL workflows using the OpenMetadata Python SDK. This approach allows data engineers and developers to integrate data quality validation directly into their data pipelines, ensuring data quality is verified at every stage of the data lifecycle.

Traditional data quality testing often requires manual configuration through UIs or separate workflow systems. Data Quality as Code brings several advantages:

  • Integration with ETL workflows: Run data quality tests directly within your existing Python-based ETL pipelines
  • Version control: Manage test definitions alongside your code in version control systems
  • Developer-friendly: Use familiar Python syntax and IDE features for test development
  • Programmatic control: Dynamically generate tests based on data discovery or metadata
  • Immediate feedback: Validate data transformations before loading to destinations
  • Shared responsibility: Data stewards define tests in OpenMetadata UI, engineers execute them in code

Execute data quality tests against tables cataloged in OpenMetadata:

Validate pandas DataFrames before loading them to destinations:

Define tests in three flexible ways:

  1. Inline code: Define tests directly in your Python code
  2. From OpenMetadata: Load test definitions configured in the OpenMetadata UI
  3. From YAML files: Load test configurations from YAML workflow files

Access all test cases supported by OpenMetadata, covering:

  • Table tests: Row counts, column counts, custom SQL queries, table diffs
  • Column tests: Null checks, uniqueness, regex patterns, value ranges, statistical metrics

Validate data after extraction and transformation, before loading:

Data stewards define tests in the UI, engineers run them in pipelines:

Validate large datasets processed in chunks:

  • Python 3.10 or higher
  • openmetadata-ingestion package version 1.11.0.0 or later
  • Access to an OpenMetadata instance (1.11.0 or later)
  • Valid JWT token for authentication

Data Quality as Code integrates seamlessly with OpenMetadata's existing data quality infrastructure:

  1. Test Definitions: Tests can be defined in code, loaded from OpenMetadata, or imported from YAML files
  2. Execution Engine: Leverages OpenMetadata's proven test execution engine
  3. Result Publishing: Test results can be published back to OpenMetadata for visualization and alerting
  4. Service Connections: Automatically uses service connections configured in OpenMetadata

Ready to get started? Follow the Getting Started guide to install the SDK and run your first data quality test.