Skip to main content

Great Expectations

For Data Quality tests the open source python package Great Expectations stands out from the crowd. For those of you who don’t know, Great Expectations is a shared, open standard for data quality. It helps data teams eliminate pipeline debt, through data testing, documentation, and profiling. Learn more about the product in their documentation. With this tutorial, we show you how to configure Great Expectations to integrate with OpenMetadata and ingest your test results to your table service page.
Great Expectations 1.3 or later is required.OpenMetadata 2.0 removes support for the Great Expectations 0.18 line. It also removes the OpenMetadataValidationAction1xx class and the metadata.great_expectations.action1xx module that shipped alongside it during the transition — use OpenMetadataValidationAction from metadata.great_expectations.action instead.Great Expectations 1.x removed the great_expectations CLI and the YAML checkpoint file. You now define checkpoints in Python and pass the OpenMetadata action as an object rather than as an action_list entry. See Upgrade Prerequisites for the full list of breaking changes.

Requirements

OpenMetadata Requirements

You’ll need OpenMetadata version 2.0 or later. On 1.13 and earlier, the Great Expectations 1.x action ships separately, under the great-expectations-1xx extra as OpenMetadataValidationAction1xx — see the 1.13 version of this page. To deploy OpenMetadata, follow the procedure to Try OpenMetadata in Docker. Before ingesting your tests results from Great Expectations you will need to have your table metadata ingested into OpenMetadata. Follow the instruction in the Connectors section to learn more.

Python Requirements

Install the OpenMetadata Great Expectations submodule, which brings in great-expectations~=1.3:

Great Expectations Setup

Create your config.yaml file

To ingest Great Expectations results in OpenMetadata, you will need to specify your OpenMetadata security configuration for the REST endpoint. This configuration file needs to be located inside the directory you pass as config_file_path and named config.yaml.
You can use environment variables in your configuration file by simply using {{ env('<MY_ENV_VAR>') }}. These will be parsed and rendered at runtime allowing you to securely create your configuration and commit it to your favorite version control tool. As we support multiple security configurations, you can check out the Enable Security section for more details on how to set the securityConfig part of the yaml file. Great Expectations config file

Add the action to your checkpoint

Instantiate OpenMetadataValidationAction and pass it to the actions list of your checkpoint:
Properties:
  • config_file_path: The path to the directory holding the config.yaml file that describes your OpenMetadata server connection.
  • database_service_name: [Optional] The name of the service in OpenMetadata. If not specified and 2 tables have the same name in 2 different OpenMetadata services, the action will fail.
  • database_name: [Optional] The database name as it appears in OpenMetadata. When omitted, the action uses the database of the execution engine the expectations ran against.
  • schema_name: [Optional] The schema name as it appears in OpenMetadata. For table assets the action reads this from the batch spec when present. Defaults to default if not specified.
  • table_name: [Optional] The table name as it appears in OpenMetadata. For table assets the action reads this from the batch spec when present. Required for query assets, where the action can’t determine the table automatically.
  • expectation_suite_table_config_map: [Optional] A dictionary mapping expectation suite names to their target OpenMetadata tables. Required when running multi-table checkpoints, where different expectation suites should send results to different tables. Each entry specifies the database_name, schema_name, and table_name for routing validation results.
Every part of the table name has to resolve before the action writes anything. The action looks in three places: its own configuration, the suite mapping, and the batch spec. If it can’t determine the database, schema, or table, the run fails with an error naming the missing parts instead of writing to the wrong table.

Adding a description to your test cases

The action copies the description set in an expectation’s meta to the OpenMetadata test case:
Expectations without a meta description are still ingested; they simply produce a test case with no description.

Run your checkpoint

Great Expectations 1.x removed the CLI, so checkpoints are run from Python:
Once the run completes, the test cases and their results appear on the table’s Data Quality tab in OpenMetadata.

Multi-Table Checkpoints

When validating multiple tables in a single checkpoint, use the expectation_suite_table_config_map parameter to route validation results to the correct OpenMetadata tables. This is necessary because:
  • Each expectation suite might target a different table.
  • The checkpoint action needs to know where to send each suite’s results.
  • Without the mapping, all results would attempt to go to the same default table.
This matters most for query assets: A query asset’s batch spec carries the query, not the table it reads from, so the mapping is the only way the action can tell where the results belong.
Any suite not present in the map falls back to the database_name / schema_name / table_name set on the action.

Test Results

Each expectation becomes a test case in OpenMetadata, and each run adds a result to it. Results report row counts:
The action doesn’t report percentages such as unexpected_percent and missing_percent. OpenMetadata charts every result value of a test case on a single axis, so a percentage plotted next to a row count is flattened into the baseline and unreadable. Divide unexpected_count by element_count if you need the percentage.

List of Great Expectations Supported Test

We currently only support a certain number of Great Expectations tests. The full list can be found in the Tests section.