Skip to main content

dscribe-dq

Run dScribe data quality rules against your Databricks or MSSQL databases and write the results back to dScribe.

For library internals, architecture, and contributing, see DEVELOPMENT.md.

Prerequisites

  • A dScribe account with at least one asset that has data quality rules defined in its ODCS spec
  • Your dScribe API key (Settings → API keys in the dScribe UI)
  • The asset UUID you want to validate
  • Access to the database the rules target (Databricks or MSSQL)

Installation

pip install dscribe-dq

How it works

Initialize DScribeDQ once with your credentials, then call run_validation with a list of post-processors. Post-processors are small pipeline steps that run in order after validation — writing results back to dScribe, uploading failed-row CSVs, generating reports, etc.

DScribeDQ(credentials) → dq.run_validation(connector_config, postprocessors=[...])

The only post-processor built into the SDK is write_back_to_dscribe, which posts pass/fail results to dScribe so the asset's quality status updates in the UI.

Quickstart

1. Find your asset ID and API key

In the dScribe UI, open the asset you want to validate. The asset ID is the UUID in the URL:

https://app.dscribe.cloud/catalog/assets/337eaa9e-47ed-4b37-a124-050d4932a520
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Your API key is under Settings → API keys.

2. Run validation and write back to dScribe

from dscribe_dq import DScribeDQ

dq = DScribeDQ(
    api_key="<your-api-key>",
    base_url="https://app.dscribe.cloud/catalog/api",
    asset_id="337eaa9e-47ed-4b37-a124-050d4932a520",
)

ctx = dq.run_validation(
    source_configs={
        # key must match the server id in the ODCS servers block
        "09bcc0f9-9d21-460d-9cb9-942b00e360bf": {
            "type": "databricks",
            "host": "adb-858283489583940.0.azuredatabricks.net",
            "client_id": "<client-id>",
            "client_secret": "<client-secret>",
            "tenant_id": "<tenant-id>",
            "http_path": "/sql/1.0/warehouses/abc123def456",
            "catalog": "hive_metastore",   # optional
            "schema": "default",           # optional
        }
    },
    postprocessors=[dq.write_back_to_dscribe()],
)

Each rule in dScribe gets a lastCheckStatus (passed or failed), lastCheckTimestamp, and failure metrics added to its customProperties after the pipeline runs.

Databricks notebook

%pip install dscribe-dq
from dscribe_dq import DScribeDQ

dq = DScribeDQ(
    api_key=dbutils.secrets.get(scope="dscribe-dq", key="DSCRIBE_API_KEY"),
    base_url="https://app.dscribe.cloud/catalog/api",
    asset_id="<your-asset-uuid>",
)

ctx = dq.run_validation(
    source_configs={
        "<server-id>": {
            "type": "databricks",
            "host": spark.conf.get("spark.databricks.workspaceUrl"),
            "client_id": dbutils.secrets.get(scope="dscribe-dq", key="CLIENT_ID"),
            "client_secret": dbutils.secrets.get(scope="dscribe-dq", key="CLIENT_SECRET"),
            "tenant_id": dbutils.secrets.get(scope="dscribe-dq", key="TENANT_ID"),
            "http_path": "/sql/1.0/warehouses/<warehouse-id>",
        }
    },
    postprocessors=[dq.write_back_to_dscribe()],
)

The http_path can be found in the Databricks UI under SQL Warehouses → your warehouse → Connection details.

Connecting to MSSQL

SQL Server authentication:

source_configs={
    "<server-id>": {
        "type": "sqlserver",
        "host": "your-server.database.windows.net",
        "database": "your-db",
        "schema": "SalesLT",
        "authentication": "SQL Server",
        "username": "your-user",
        "password": "your-password",
    }
}

Entra ID (service principal) authentication:

source_configs={
    "<server-id>": {
        "type": "sqlserver",
        "host": "your-server.database.windows.net",
        "database": "your-db",
        "schema": "SalesLT",
        "authentication": "Entra ID",
        "tenant_id": "<tenant-id>",
        "client_id": "<client-id>",
        "client_secret": "<client-secret>",
    }
}

Multiple sources in one call

If your asset has rules targeting both Databricks and MSSQL, pass both in source_configs. Rules are automatically grouped by source and run independently:

source_configs={
    "<mssql-server-id>": {"type": "sqlserver", ...},
    "<databricks-server-id>": {"type": "databricks", ...},
}

CI/CD usage (env vars)

For automated pipelines, set env vars and call the module-level run_validation directly:

DSCRIBE_API_KEY=...
DSCRIBE_ASSET_ID=...
DSCRIBE_BASE_URL=...
DATABRICKS_HOST=...
DATABRICKS_CLIENT_ID=...
DATABRICKS_CLIENT_SECRET=...
DATABRICKS_TENANT_ID=...
DATABRICKS_HTTP_PATH=...
from dscribe_dq import run_validation

ctx = run_validation()  # reads all config from env vars

Options

DScribeDQ.__init__

Parameter Type Default Description
api_key str dScribe API key (or set DSCRIBE_API_KEY env var)
base_url str dScribe API base URL (or set DSCRIBE_BASE_URL)
asset_id str Asset UUID to validate (or set DSCRIBE_ASSET_ID)
log_level str INFO DEBUG, INFO, RESULT, WARNING, ERROR

DScribeDQ.run_validation

Parameter Type Default Description
source_configs dict {} Per-source connection settings keyed by server ID from ODCS spec
connector_config dict {} Default connection settings used when no per-source config found
collect_failed_rows bool True Fetch the actual failing rows for each failed rule
enable_profiling bool False Compute descriptive statistics (row count, null counts, etc.)
postprocessors list [] Pipeline steps to run after validation in order

Supported ODCS metrics

ODCS metric What it checks
rowCount Row count within expected bounds
nullValues No NULL values in a column
missingValues No missing/empty values in a column
duplicateValues All values in a column (or column set) are unique
invalidValues Values match an allowed list or regex pattern

Environment variable reference

Variable Description
DSCRIBE_API_KEY dScribe API key
DSCRIBE_ASSET_ID Asset UUID to validate
DSCRIBE_BASE_URL dScribe API base URL
DATABRICKS_HOST Databricks workspace hostname
DATABRICKS_CLIENT_ID Azure AD service principal client ID
DATABRICKS_CLIENT_SECRET Azure AD service principal client secret
DATABRICKS_TENANT_ID Azure AD tenant ID
DATABRICKS_HTTP_PATH SQL warehouse HTTP path
DATABRICKS_WAREHOUSE_ID SQL warehouse ID (alternative to HTTP path)
DATABRICKS_CATALOG Default Unity Catalog catalog name
DATABRICKS_SCHEMA Default schema name
MSSQL_HOST MSSQL server hostname
MSSQL_DATABASE MSSQL database name
MSSQL_USER SQL Server username
MSSQL_PASSWORD SQL Server password
MSSQL_AUTH SQL Server or Entra ID
MSSQL_TENANT_ID Azure tenant ID (Entra ID auth only)
MSSQL_CLIENT_ID Azure client ID (Entra ID auth only)
MSSQL_CLIENT_SECRET Azure client secret (Entra ID auth only)
HANA_HOST SAP HANA / Data Warehouse Cloud hostname
HANA_PORT SQL port — 443 for SAP Data Warehouse Cloud, tenant SQL port (e.g. 3<instance>15) on-prem
HANA_DATABASE Tenant database name (on-prem MDC routing; not needed for DWC)
HANA_SCHEMA Schema containing the target table
HANA_TABLE Table name to validate
HANA_USER HANA username
HANA_PASSWORD HANA password
HANA_ENCRYPT true or false (default true)
HANA_VALIDATE_CERT true or false (default true)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dscribe_dq-1.0.8.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dscribe_dq-1.0.8-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file dscribe_dq-1.0.8.tar.gz.

File metadata

  • Download URL: dscribe_dq-1.0.8.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.14 Darwin/24.6.0

File hashes

Hashes for dscribe_dq-1.0.8.tar.gz
Algorithm Hash digest
SHA256 ed5411f171d06f5496a6f13b34b8768b37486bd932e7bff48abf0c7c3b10bee4
MD5 29a909bc39507e9c7d1795483b9892a2
BLAKE2b-256 894ebd036f71ce327d92eb5094b2acc4b8d103a9b107fc2aef0f51aedf39f2ff

See more details on using hashes here.

File details

Details for the file dscribe_dq-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: dscribe_dq-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.14 Darwin/24.6.0

File hashes

Hashes for dscribe_dq-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b336136f6a2adf3452c672ca6c12194d1c01301f178df099ea48aea72fbfe4e1
MD5 d1421e30d3f082aaa783736d9e72470e
BLAKE2b-256 c555b41839570d4efdf0bd287b6465f9cd71740bce0e892c445a1b1d0368fe91

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page