Skip to main content

Wrapper for Great Expectations to fit the requirements of the Gemeente Amsterdam.

Project description

Introduction

This repository contains functions that will ease the use of Great Expectations. Users can input data and data quality rules and get results in return.

DISCLAIMER: The package is in MVP phase

Getting started

Install the dq suite on your compute, for example by running the following code in your workspace:

pip install dq-suite-amsterdam
import dq_suite

Load your data in dataframes, give them a table_name, and create a list of all dataframes:

df = spark.read.csv(csv_path+file_name, header=True, inferSchema=True) #example using csv
df.table_name = "showcase_table"
dfs = [df]
  • Define 'dfs' as a list of dataframes that require a dq check
  • Define 'dq_rules' as a JSON as shown in dq_rules_example.json in this repo
  • Define a name for your dq check, in this case "showcase"
dq_suite.df_check(dfs, dq_rules, "dpxx_dev", "showcase", spark)

Export the schema from Unity Catalog to the Input Form

In order to output the schema from Unity Catalog, use the following commands (using the required schema name):

schema_output = dq_suite.export_schema('schema_name', spark)
print(schema_output)

Copy the string to the Input Form to quickly ingest the schema in Excel.

Validate the schema of a table

It is possible to validate the schema of an entire table to a schema definition from Amsterdam Schema in one go. This is done by adding two fields to the "dq_rules" JSON when describing the table (See: https://github.com/Amsterdam/dq-suite-amsterdam/blob/main/dq_rules_example.json).

You will need:

  • validate_table_schema: the id field of the table from Amsterdam Schema
  • validate_table_schema_url: the url of the table or dataset from Amsterdam Schema

The schema definition is converted into column level expectations (expect_column_values_to_be_of_type) on run time.

Known exceptions

The functions can run on Databricks using a Personal Compute Cluster or using a Job Cluster. Using a Shared Compute Cluster will results in an error, as it does not have the permissions that Great Expectations requires.

Updates

Version 0.1: Run a DQ check for a dataframe

Version 0.2: Run a DQ check for multiple dataframes

Version 0.3: Refactored I/O

Version 0.4: Added schema validation with Amsterdam Schema per table

Version 0.5: Export schema from Unity Catalog

Version 0.6: The results are written to tables in the "dataquality" schema

Project details


Download files

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

Source Distribution

dq_suite_amsterdam-0.6.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

dq_suite_amsterdam-0.6.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file dq_suite_amsterdam-0.6.0.tar.gz.

File metadata

  • Download URL: dq_suite_amsterdam-0.6.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dq_suite_amsterdam-0.6.0.tar.gz
Algorithm Hash digest
SHA256 cc42e67f7e725f9f554bd000a5203f1384a5410776ca0878da3345c334d098c9
MD5 3327750ac0399ac4a15fcc828e012169
BLAKE2b-256 3ac4cc253cede0cf24191a7f582e5fa92b9de08dc82967aaf4d47f671ff8e1e4

See more details on using hashes here.

File details

Details for the file dq_suite_amsterdam-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dq_suite_amsterdam-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a04d72a5ae47f0c89332d2173ded478e65494b37ad6e86c964fa165e82c41c2
MD5 e63692e3a54a5b2501ad5f97943596c3
BLAKE2b-256 a272ae472805980eecdb955317f06b3e1b94a5811a9909f1f4c8f01aa2ed8e56

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page