Metadata-Version: 2.4
Name: odcr
Version: 0.2.2
Summary: Open Data Contract Runtime: enforce ODCS data contracts where data lands, reconcile source and target, and trace every batch end to end, on any database, lake or cloud.
Author: sulfibashy, odcr contributors
Maintainer: sulfibashy
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/sulfibashy/odcr
Project-URL: Documentation, https://sulfibashy.github.io/odcr/
Project-URL: Repository, https://github.com/sulfibashy/odcr
Project-URL: Issues, https://github.com/sulfibashy/odcr/issues
Project-URL: Changelog, https://github.com/sulfibashy/odcr/blob/main/CHANGELOG.md
Keywords: data contracts,ODCS,data quality,data observability,reconciliation,data engineering,databricks,snowflake,bigquery,duckdb,sql server,mongodb,adls
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=6.0
Provides-Extra: duckdb
Requires-Dist: duckdb>=1.1; extra == "duckdb"
Provides-Extra: files
Requires-Dist: duckdb>=1.1; extra == "files"
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
Provides-Extra: mysql
Requires-Dist: PyMySQL>=1.1; extra == "mysql"
Provides-Extra: sqlserver
Requires-Dist: pyodbc>=5.0; extra == "sqlserver"
Requires-Dist: python-tds>=1.15; extra == "sqlserver"
Provides-Extra: synapse
Requires-Dist: pyodbc>=5.0; extra == "synapse"
Requires-Dist: python-tds>=1.15; extra == "synapse"
Provides-Extra: fabric
Requires-Dist: pyodbc>=5.0; extra == "fabric"
Requires-Dist: python-tds>=1.15; extra == "fabric"
Provides-Extra: oracle
Requires-Dist: oracledb>=2.0; extra == "oracle"
Provides-Extra: db2
Requires-Dist: ibm_db>=3.2; extra == "db2"
Provides-Extra: trino
Requires-Dist: trino>=0.330; extra == "trino"
Provides-Extra: clickhouse
Requires-Dist: clickhouse-connect>=0.7; extra == "clickhouse"
Provides-Extra: vertica
Requires-Dist: vertica-python>=1.3; extra == "vertica"
Provides-Extra: teradata
Requires-Dist: teradatasql>=20.0; extra == "teradata"
Provides-Extra: saphana
Requires-Dist: hdbcli>=2.19; extra == "saphana"
Provides-Extra: hive
Requires-Dist: PyHive[hive_pure_sasl]>=0.7; extra == "hive"
Provides-Extra: impala
Requires-Dist: impyla>=0.19; extra == "impala"
Provides-Extra: kafka
Requires-Dist: confluent-kafka>=2.3; extra == "kafka"
Requires-Dist: duckdb>=1.1; extra == "kafka"
Provides-Extra: eventhubs
Requires-Dist: confluent-kafka>=2.3; extra == "eventhubs"
Requires-Dist: duckdb>=1.1; extra == "eventhubs"
Requires-Dist: azure-identity>=1.15; extra == "eventhubs"
Provides-Extra: snowflake
Requires-Dist: snowflake-connector-python>=3.6; extra == "snowflake"
Provides-Extra: databricks
Requires-Dist: databricks-sql-connector>=3.1; extra == "databricks"
Provides-Extra: bigquery
Requires-Dist: google-cloud-bigquery>=3.17; extra == "bigquery"
Provides-Extra: redshift
Requires-Dist: redshift_connector>=2.1; extra == "redshift"
Provides-Extra: athena
Requires-Dist: PyAthena>=3.0; extra == "athena"
Provides-Extra: mongodb
Requires-Dist: pymongo>=4.6; extra == "mongodb"
Provides-Extra: cosmosdb
Requires-Dist: azure-cosmos>=4.5; extra == "cosmosdb"
Requires-Dist: azure-identity>=1.15; extra == "cosmosdb"
Provides-Extra: lint
Requires-Dist: datacontract-cli>=0.10; extra == "lint"
Provides-Extra: keyring
Requires-Dist: keyring>=24; extra == "keyring"
Provides-Extra: microsoft365
Requires-Dist: azure-identity>=1.15; extra == "microsoft365"
Provides-Extra: aws-ses
Requires-Dist: boto3>=1.34; extra == "aws-ses"
Provides-Extra: all
Requires-Dist: duckdb>=1.1; extra == "all"
Requires-Dist: psycopg[binary]>=3.1; extra == "all"
Requires-Dist: PyMySQL>=1.1; extra == "all"
Requires-Dist: pyodbc>=5.0; extra == "all"
Requires-Dist: python-tds>=1.15; extra == "all"
Requires-Dist: oracledb>=2.0; extra == "all"
Requires-Dist: trino>=0.330; extra == "all"
Requires-Dist: clickhouse-connect>=0.7; extra == "all"
Requires-Dist: vertica-python>=1.3; extra == "all"
Requires-Dist: teradatasql>=20.0; extra == "all"
Requires-Dist: hdbcli>=2.19; extra == "all"
Requires-Dist: PyHive[hive_pure_sasl]>=0.7; extra == "all"
Requires-Dist: impyla>=0.19; extra == "all"
Requires-Dist: confluent-kafka>=2.3; extra == "all"
Requires-Dist: snowflake-connector-python>=3.6; extra == "all"
Requires-Dist: databricks-sql-connector>=3.1; extra == "all"
Requires-Dist: google-cloud-bigquery>=3.17; extra == "all"
Requires-Dist: redshift_connector>=2.1; extra == "all"
Requires-Dist: PyAthena>=3.0; extra == "all"
Requires-Dist: pymongo>=4.6; extra == "all"
Requires-Dist: azure-cosmos>=4.5; extra == "all"
Requires-Dist: azure-identity>=1.15; extra == "all"
Requires-Dist: keyring>=24; extra == "all"
Requires-Dist: boto3>=1.34; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov>=5; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Requires-Dist: duckdb>=1.1; extra == "dev"
Requires-Dist: psycopg[binary]>=3.1; extra == "dev"
Requires-Dist: PyMySQL>=1.1; extra == "dev"
Requires-Dist: python-tds>=1.15; extra == "dev"
Requires-Dist: oracledb>=2.0; extra == "dev"
Requires-Dist: trino>=0.330; extra == "dev"
Requires-Dist: pymongo>=4.6; extra == "dev"
Requires-Dist: mongomock>=4.1; extra == "dev"
Requires-Dist: keyring>=24; extra == "dev"
Requires-Dist: clickhouse-connect>=0.7; extra == "dev"
Requires-Dist: confluent-kafka>=2.3; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
Dynamic: license-file

<div align="center">

# odcr — Open Data Contract Runtime

**Check every dataset against its data contract the moment it lands — on any database, lake or cloud.**

[![CI](https://github.com/sulfibashy/odcr/actions/workflows/ci.yml/badge.svg)](https://github.com/sulfibashy/odcr/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/odcr.svg)](https://pypi.org/project/odcr/)
[![Python](https://img.shields.io/pypi/pyversions/odcr.svg)](https://pypi.org/project/odcr/)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
[![Docs](https://img.shields.io/badge/docs-sulfibashy.github.io%2Fodcr-indigo.svg)](https://sulfibashy.github.io/odcr/)
[![ODCS](https://img.shields.io/badge/contracts-ODCS%20v3-green.svg)](https://github.com/bitol-io/open-data-contract-standard)

[Documentation](https://sulfibashy.github.io/odcr/) · [Architecture](docs/architecture.md) · [Quickstart](#quickstart) · [Adapters](#adapters) · [Examples](examples/) · [Contributing](CONTRIBUTING.md)

</div>

---

odcr reads [ODCS](https://github.com/bitol-io/open-data-contract-standard) data contracts from your **central
contract repository** and enforces them wherever data arrives — a table, a lakehouse, or files in ADLS, S3, GCS
or a landing folder — however it got there: **batch, streaming, CDC, events or file drops**.

For every batch, micro-batch or file, odcr:

| | |
| --- | --- |
| **Checks** | schema (missing columns, wrong types, drift) and quality rules (nulls, duplicates, valid values, row counts, custom SQL) |
| **Decides** | pass, warn, or fail and quarantine — the exit code stops your pipeline |
| **Notifies** | the source team and the platform team: Slack, Teams, email, Google Chat, Discord, PagerDuty, Opsgenie, webhooks |
| **Logs** | every run, check and alert in meta tables created **on the platform itself** |
| **Reconciles** | source against target per batch — even Oracle → Snowflake or ADLS files → Databricks |
| **Traces** | each batch from source to consumption, flagging the stage where rows were lost |

## Quickstart

```bash
pip install odcr-postgres                     # pick your platform: odcr adapters
odcr init my_contracts --adapter postgres        # creates a full project, like dbt init
cd my_contracts
cp .env.example .env                             # fill in the connection (Windows: copy)
odcr doctor                                      # driver, TLS, permissions, meta tables, contracts
odcr seed                                        # optional sample data
odcr run --contract-id orders --batch-id batch-002 --where "load_id = 'batch-002'"
```

```text
Contract orders v1.0.0 batch=batch-002: FAIL
  orders: FAIL (4 rows, 4 failed, 0 warnings)
    - [failed] orders.order_id.unique: expected = 0, got 1 (unique: no duplicate values)
    - [failed] orders.customer_id.required: expected = 0, got 1 (required: no NULL values)
    - [failed] orders.status.invalidValues: expected = 0, got 1
    - [failed] orders.no_negative_amounts: expected = 0, got 1 (Amounts must never be negative)
```

Then check new data automatically as it lands:

```bash
odcr watch --contract-id orders --batch-column load_id          # every new batch in a table
odcr watch --contract-id orders -C lake                          # every new file in ADLS / S3 / GCS
```

## Adapters

| | Platforms | Install |
| --- | --- | --- |
| **Files** | Parquet / CSV / JSON in local folders, network shares, **ADLS Gen2**, Azure Blob, **S3**, **GCS**, MinIO | `odcr-files` |
| **Embedded** | DuckDB, SQLite | `odcr-duckdb`, `odcr` |
| **Streaming** | **Apache Kafka** (Confluent, MSK, Redpanda, Aiven), **Azure Event Hubs** | `odcr-kafka` `odcr-eventhubs` |
| **On-premise / open source** | PostgreSQL (Greenplum, CockroachDB, YugabyteDB, TimescaleDB), MySQL, MariaDB, **SQL Server**, **Oracle**, **IBM Db2**, **Teradata**, **SAP HANA**, **Vertica**, **ClickHouse**, Trino / Starburst / Presto | `odcr-postgres` `odcr-mysql` `odcr-sqlserver` `odcr-oracle` `odcr-db2` `odcr-teradata` `odcr-saphana` `odcr-vertica` `odcr-clickhouse` `odcr-trino` |
| **Hadoop** | **Hive**, **Spark SQL** (Thrift server), **Impala** — Cloudera, EMR, Dataproc, HDInsight | `odcr-hive` `odcr-impala` |
| **Azure** | **Databricks**, **Synapse Analytics**, **Fabric Warehouse**, Azure SQL, **Cosmos DB**, **Event Hubs**, Azure PostgreSQL / MySQL | `odcr-databricks` `odcr-synapse` `odcr-fabric` `odcr-sqlserver` `odcr-cosmosdb` `odcr-eventhubs` |
| **AWS** | Databricks, **Redshift**, **Athena**, Aurora / RDS, DocumentDB | `odcr-databricks` `odcr-redshift` `odcr-athena` `odcr-postgres` `odcr-mongodb` |
| **GCP** | Databricks, **BigQuery**, Cloud SQL, AlloyDB | `odcr-databricks` `odcr-bigquery` `odcr-postgres` |
| **Multi-cloud** | **Snowflake**, **MongoDB** / Atlas, ClickHouse Cloud, Teradata VantageCloud | `odcr-snowflake` `odcr-mongodb` `odcr-clickhouse` `odcr-teradata` |

26 adapters; `pip install odcr-all` installs every driver. Each has a ready-to-run reference project in
[`examples/`](examples/) and a [documentation page](https://sulfibashy.github.io/odcr/adapters/).
**Informatica, Ab Initio, Azure Data Factory, SSIS, Airflow and Databricks Workflows** call odcr after they land
data — see [Integrations](https://sulfibashy.github.io/odcr/integrations/).

## A contract

```yaml
apiVersion: v3.0.2
kind: DataContract
id: orders
version: 1.0.0
support:                                    # the source team is notified here
  - {channel: "#orders-alerts", tool: slack, url: "${ORDERS_SLACK_WEBHOOK}"}
  - {channel: orders, tool: teams, url: "${ORDERS_TEAMS_WEBHOOK}"}
  - {channel: orders-team@example.com, tool: email, url: "mailto:orders-team@example.com"}
schema:
  - name: orders
    physicalName: sales.orders              # or abfss://landing@lake.dfs.core.windows.net/orders/*.parquet
    properties:
      - {name: order_id, logicalType: integer, primaryKey: true}
      - name: status
        logicalType: string
        quality:
          - {type: library, metric: invalidValues, arguments: {validValues: [NEW, PAID, SHIPPED]}, mustBe: 0}
      - name: amount
        logicalType: number
        quality:
          - {type: library, metric: nullValues, mustBeLessOrEqualTo: 1, unit: percent, severity: warning}
    quality:
      - {type: library, metric: rowCount, mustBeGreaterThan: 0}
      - {type: sql, query: "SELECT COUNT(*) FROM {object} WHERE amount < 0", mustBe: 0}
```

## Runs everywhere

- **Operating systems:** Windows, macOS, Linux and Unix servers — tested in CI on all three major ones.
- **Install:** `pip`, `pipx`, offline wheelhouses for air-gapped servers, the [Dockerfile](Dockerfile), Databricks
  libraries, Azure Functions, AWS Lambda.
- **Security:** TLS with verified certificates by default; corporate CA bundles and proxies; secrets from
  environment variables, `.env` or secret files; managed identities, IAM roles, key-pair and OAuth. See
  [Security](https://sulfibashy.github.io/odcr/security/).

## Python API

```python
from odcr import ContractRepository, run_contract
from odcr.adapters import get_adapter
from odcr.config import load_config

config = load_config("odcr.yaml")
contract = ContractRepository.from_config(config).get("orders")
with get_adapter(config.connection("main")) as db:
    result = run_contract(contract, db, config, batch_id="42", where="load_id = '42'")
    if not result.passed:
        raise SystemExit(result.summary())
```

Airflow: `from odcr.integrations.airflow import OdcrContractOperator`.

## Contributing

odcr is community-built. Adapters are the easiest way in: [adding one](docs/contributing/adding-an-adapter.md)
is ~50 lines, and the whole end-to-end suite then runs against your platform. Start with
[CONTRIBUTING.md](CONTRIBUTING.md) and issues labelled `good first issue`.

Licensed under the [Apache License 2.0](LICENSE).
