Data quality (advanced)
This feature is in public preview
This page covers more in-depth details about dltHub data quality features, such as metrics and checks. It shows the full flexibility available for advanced use cases. It can also serve as an FAQ and helper for debugging.
Note that these APIs are more likely to change than the basics page.
Metrics and checks are DltSource objects
Internally, metrics and checks are defined as dlt.source objects that are executed by the pipeline. You can interact with these objects directly, unlocking the ability to:
- load data into destination A and write metrics and checks to destination B
- run data quality checks and metrics disjointed from the primary
pipeline.run()(for example, on a schedule, after another trigger, etc.) - dynamically modify metrics and checks to execute via Python code
- have a central data quality pipeline that you run for multiple pipelines / datasets
Metrics and checks use a special dlt.Schema
Currently, a dlt.Dataset is associated with a single dlt.Schema. This defines what tables are known and available to the dataset's API (for example, dataset.table(...)).
But a dlt.Pipeline can be associated with multiple dlt.Schema, such as when loading several sources.
The data quality metrics and checks sources have a dedicated _dlt_data_quality schema with internal tables for metrics and checks results. These tables are not directly visible via the dlt.Dataset API. (this may change in the future)
The dq.read_metric() and dq.read_check() retrieve data from these internal tables.