Metadata-Version: 2.4
Name: dq-kernel
Version: 0.4.0
Summary: A flexible data quality framework with engine extensibility using Python reflection
License: Apache-2.0
License-File: LICENSE
Keywords: data-quality,spark,deequ,great-expectations,data-validation
Author: Data Quality Framework Contributors
Requires-Python: >=3.12,<3.14
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Quality Assurance
Provides-Extra: arrow
Provides-Extra: aws
Provides-Extra: cron
Provides-Extra: databricks
Provides-Extra: deequ
Provides-Extra: delta
Provides-Extra: dqx
Provides-Extra: greatexpectations
Provides-Extra: otel
Provides-Extra: pandera
Provides-Extra: spark
Provides-Extra: sqlalchemy
Requires-Dist: boto3 (>=1.26.0,<2.0.0) ; extra == "aws"
Requires-Dist: cron-schedule-triggers (>=0.0.11,<0.0.12) ; extra == "cron" or extra == "databricks"
Requires-Dist: databricks-labs-dqx (>=0.17.2,<0.18) ; (python_version == "3.12") and (extra == "dqx")
Requires-Dist: databricks-sdk (>=0.123,<0.171) ; extra == "databricks"
Requires-Dist: delta-spark (>=3.3,<3.4) ; extra == "delta"
Requires-Dist: filelock (>=4.2.1)
Requires-Dist: great_expectations (>=1.24,<2) ; extra == "greatexpectations"
Requires-Dist: msgpack (>=1.2.3)
Requires-Dist: opentelemetry-api (>=1.25,<2) ; extra == "otel"
Requires-Dist: pandera (>=0.36,<0.37) ; extra == "pandera"
Requires-Dist: pyarrow (>=16,<27) ; extra == "arrow"
Requires-Dist: pyasn1 (>=0.6.5)
Requires-Dist: pydeequ (==1.7.0) ; extra == "deequ"
Requires-Dist: pyhocon (>=0.3.59,<0.4.0)
Requires-Dist: pyspark (==3.5.9) ; extra == "spark" or extra == "delta"
Requires-Dist: pywin32-ctypes (>=0.2.0,<0.3.0) ; sys_platform == "win32"
Requires-Dist: pyyaml (>=6.0,<7.0)
Requires-Dist: requests (>=2.33.0,<3.0.0)
Requires-Dist: sqlalchemy (>=2.0,<2.2) ; extra == "sqlalchemy"
Project-URL: Documentation, https://github.com/anvai-labs/dq-kernel#documentation
Project-URL: Homepage, https://github.com/anvai-labs/dq-kernel
Project-URL: Repository, https://github.com/anvai-labs/dq-kernel
Description-Content-Type: text/markdown

# dq-kernel

Certifiable data-quality evidence engine for lakehouse pipelines. Semantically
versioned rules, exact-arithmetic evaluation, and machine-checkable evidence —
engine-agnostic by design.

## Install

```bash
pip install dq-kernel[spark]
```

Requires Python 3.12/3.13. The Spark path needs Java 17 and a Spark 3.5.9 runtime.

Every release is built, signed and attested by the workflow that publishes it, and nothing is
published before it has been checked. `pip` does not check attestations; the commands that do
are under [Releases and verifying them](docs/index.adoc) in the documentation.

Evidence can be kept in a SQL database instead of files. That sink and its Arrow path are
optional extras: `pip install dq-kernel[sqlalchemy,arrow]`.

Evidence can also come from other tools, without a Spark session: `dq.harvest` imports dbt
test results, Great Expectations validation results, or a four-column CSV or JSON file, and
`dq-import` applies the gate to them and writes the same `dq-report/v1`.

Portable rules also run with no Spark session at all, over Parquet, Arrow, CSV or JSON
files, and write the same report: `pip install 'dq-kernel[arrow]'`, then
`dq-run arrow_rule.conf --dataset orders=orders.parquet --report report.json`. A rule opts
in with `adapter = "arrow"`. The same rules also run as one aggregate query on a database the
data already lives in, through SQLAlchemy (`adapter = "sql"`; DuckDB is the certified lane).

A schema already written for pandera validates a pandas or a Polars frame through the same
engine contract, and its results reach the same gate: `pip install 'dq-kernel[pandera]'`.

Runs are also judged by their history: with evidence kept in a SQL database, a policy reports
stale data, a count that moved, a check failing for the first time, or a number that stands
out of the series before it (`examples/history_policies.conf`).

A rule can also act on the rows a check rejected: with an engine that tags rows (DQX first), a
`rows` block sorts the frame into valid and quarantined rows and writes each where it says
(`examples/dqx_row_outcomes.conf`).

The same packs run on a stream: `dq.streaming.per_batch` builds the callback `foreachBatch` takes,
and judges every micro-batch that carries rows (`examples/streaming_validation.conf`).

Start from the data instead of a blank rule pack: `dq-profile` summarizes a dataset, with Arrow or
Spark, and `dq-suggest` turns the summary into a draft rule pack -- for the portable checks, Deequ,
DQX or Great Expectations, in HOCON, YAML or JSON. Every rule in a draft is a warning under the gate
policy where a warning blocks nothing, so a draft never stops a pipeline.

## Quick start

```python
from dq.dq_framework import DQFramework

results = DQFramework(spark, config, default_dataframe=df).run()
```

Each result carries `check`, `success`, and bounded `details`. Evidence is
bound to dataset and rule-set digests as `dq-report/v1`.

A run explains itself: with nothing configured it is logged, one line per
notification, naming the run and each rule (`DQ_LOG_FORMAT=json` for JSON
lines). `dq.observability` is the port, with an OpenTelemetry adapter behind
the `otel` extra.

## Three semantic versions

| Version | Semantics | Example |
|---|---|---|
| counts/v1 | Completeness (present/rows) | id is 80% complete |
| groups/v1 | Grouped distinct-count bounds | Each region has ≥ 2 distinct ids |
| ranges/v1 | Value-range bounds | All values ≥ 0 and ≤ 100 |

Plans are single-semantics: compose them with `RulesetEnvelope` for mixed
rulesets and execute the whole ruleset with one call —
`dq.spark_adapter.execute_envelope(envelope, datasets)` returns the
aggregate verdict, and so does `dq.arrow_adapter.execute_envelope`, with no
Spark: it takes a pyarrow table or a pandas, Polars or DataFusion frame.

## Documentation

- [Quickstart](docs/quickstart.adoc)
- [Error catalog](docs/error-catalog.adoc)
- [ADRs](docs/decisions/adr/)
- [Roadmap and spec tracker](docs/roadmap.adoc) — every spec with status and evidence
- [Writing an engine](docs/writing-an-engine.adoc) — the engine contract, conformance suite, and a worked example
- [SPECs](docs/specs/)
- [Modernization plan](docs/modernization-plan.adoc)
- [Compute engines beyond Spark](docs/compute-engines.adoc) — the Arrow adapter and the Spark-free runner
- [Releases and verifying them](docs/index.adoc) — what a release carries, and the commands that verify it

## License

Apache-2.0

