Skip to main content

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

Project description

About dq-suite-amsterdam

This repository aims to be an easy-to-use wrapper for the data quality library Great Expectations (GX). All that is needed to get started is an in-memory Spark dataframe and a set of data quality rules - specified in a JSON file of particular formatting.

While the results of all validations are written to a data_quality schema in Unity Catalog, users can also choose to get notified via Slack or Microsoft Teams.

DISCLAIMER: The package is in MVP phase, so watch your step.

How to contribute

Want to help out? Great! Feel free to create a pull request addressing one of the open issues. Some notes for developers are located here.

Found a bug, or need a new feature? Add a new issue describing what you need.

Getting started

Following GX, we recommend installing dq-suite-amsterdam in a virtual environment. This could be either locally via your IDE, on your compute via a notebook in Databricks, or as part of a workflow.

  1. Run the following command:
pip install dq-suite-amsterdam
  1. Create the data_quality schema (and tables all results will be written to) by running the SQL notebook located here. All it needs is the name of the catalog - and the rights to create a schema within that catalog :)

  2. Get ready to validate your first table. To do so, define

  • catalog_name as the name of your catalog
  • table_name as the name of the table for which a data quality check is required. This name should also occur in the JSON file
  • dq_rule_json_path as a path to a JSON file, formatted in this way
  • df as a Spark dataframe containing the table that needs to be validated (e.g. via spark.read.csv or spark.read.table)
  1. Finally, perform the validation by running
import dq_suite

validation_settings_obj = dq_suite.ValidationSettings(spark_session=spark, 
                                                      catalog_name=catalog_name,
                                                      table_name=table_name,
                                                      check_name="name_of_check_goes_here")
dq_suite.run(json_path=dq_rule_json_path, df=df, validation_settings_obj=validation_settings_obj)

Note: Looping over multiple data frames may require a redefinition of the json_path and validation_settings variables.

See the documentation of ValidationSettings for what other parameters can be passed upon intialisation.

Known exceptions

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

  • Since this project requires Python >= 3.10, the use of Databricks Runtime (DBR) >= 13.3 is needed (click). Older versions of DBR will result in errors upon install of the dq-suite-amsterdam library.

  • At time of writing (late Aug 2024), Great Expectations v1.0.0 has just been released, and is not (yet) compatible with Python 3.12. Hence, make sure you are using the correct version of Python as interpreter for your project.

  • The run_time is defined separately from Great Expectations in df_checker. We plan on fixing it when Great Expectations has documented how to access it from the RunIdentifier object.

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

Version 0.7: Refactored the solution

Version 0.8: Implemented output historization

Version 0.9: Added dataset descriptions

Version 0.10: Switched to GX 1.0

Version 0.11: Stability and testability improvements

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.11.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

dq_suite_amsterdam-0.11.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dq_suite_amsterdam-0.11.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dq_suite_amsterdam-0.11.1.tar.gz
Algorithm Hash digest
SHA256 48f2cd6e228aef211c4643535024e0043739f9b7c5160d307d431f2b3becf4c6
MD5 de750b18605ab91d9949e31d539fd849
BLAKE2b-256 2499b45018171303949b81fb1c0ab296c92cab2eb600ce578e3362e317739627

See more details on using hashes here.

Provenance

The following attestation bundles were made for dq_suite_amsterdam-0.11.1.tar.gz:

Publisher: publish-to-pypi.yml on Amsterdam/dq-suite-amsterdam

Attestations:

File details

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

File metadata

File hashes

Hashes for dq_suite_amsterdam-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 779bf270af00b92074c7131189280618e22306f11021d926b21b575d90f4b96d
MD5 d0f1a6906816c8e7021a3866f747ce86
BLAKE2b-256 fa45db245bc9f4e3e99b76d1d15b82859faee82921560051916f0de39b71b017

See more details on using hashes here.

Provenance

The following attestation bundles were made for dq_suite_amsterdam-0.11.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Amsterdam/dq-suite-amsterdam

Attestations:

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