metadata.sdk.data_quality.runner
Class that allows running data quality checks by code
Classes:
- TestRunner – Simplified test runner for executing data quality tests on OpenMetadata tables.
metadata.sdk.data_quality.runner.TestRunner
Simplified test runner for executing data quality tests on OpenMetadata tables.
This class provides a fluent API for defining and executing data quality tests against tables in OpenMetadata. It handles test case creation, workflow configuration, and result collection.
The runner automatically fetches table metadata and service connections from OpenMetadata, builds test cases from test definitions, and executes them using the TestSuiteWorkflow.
Attributes:
- table_fqn (
str) – Fully qualified name of the table to test - client (
OpenMetadata) – OpenMetadata API client
Examples:
Functions:
- add_test – Add a test definition to be executed.
- add_tests – Add multiple test definitions at once.
- for_table – Initialize runner for a specific table FQN.
- from_yaml – Build TestRunner from a YAML workflow string.
- run – Execute all added tests and return results.
- setup – Change the default configuration for the workflow.
Parameters:
- table_fqn (
str) – Fully qualified name of the table - client (
Optional[OpenMetadata[Any, Any]]) – Optional OpenMetadata client (will create one if not provided)
metadata.sdk.data_quality.runner.TestRunner.add_test
Add a test definition to be executed.
Parameters:
- test_definition (
BaseTest) – Test definition instance (e.g., TableColumnCountToBeBetween)
Returns:
- Self for method chaining
metadata.sdk.data_quality.runner.TestRunner.add_tests
Add multiple test definitions at once.
Parameters:
- *test_definitions (
BaseTest) – Variable number of test definition instances
Returns:
- Self for method chaining
Examples:
metadata.sdk.data_quality.runner.TestRunner.client
metadata.sdk.data_quality.runner.TestRunner.config_builder
metadata.sdk.data_quality.runner.TestRunner.for_table
Initialize runner for a specific table FQN.
Parameters:
- table_fqn (
str) – Fully qualified name of the table (e.g., "MySQL.default.db.table") - client (
Optional[OpenMetadata[Any, Any]]) – Optional OpenMetadata client (will create one if not provided)
Returns:
Self– TestRunner instance
Examples:
metadata.sdk.data_quality.runner.TestRunner.from_yaml
Build TestRunner from a YAML workflow string.
metadata.sdk.data_quality.runner.TestRunner.run
Execute all added tests and return results.
Returns:
List[TestCaseResultResponse]– List of test case results
metadata.sdk.data_quality.runner.TestRunner.setup
Change the default configuration for the workflow.
Parameters:
- force_test_update (
bool) – Force test update even if tests already exist. - log_level (
LogLevels) – Log level to use. - raise_on_error (
bool) – Raise exception if test data already exists. - success_threshold (
int) – threshold below which the test will fail. - enable_streamable_logs (
bool) – Enable streamable logs.
Returns:
- None