Ensuring data quality in Delta Lake
Project description
rezQ
Descrição
rezQ is a Python library designed to help ensure data quality in Delta Lake. It provides functions to add constraints to data, remove existing constraints, and separate a DataFrame based on those constraints.
Instalação
You can install rezQ using pip:
pip install rezq
Add constraint
To add a constraint to a delta table:
from rezq import add_constraint
from delta import DeltaTable
delta_table = DeltaTable.forPath(spark, 'my_table_path')
add_constraint(spark_session=spark,
delta_table=delta_table,
constraint_name='age_higher_than_20',
constraint_code='age > 20')
Add constraints
To add multiple a constraints to a delta table:
from rezq import add_constraints
from delta import DeltaTable
delta_table = DeltaTable.forPath(spark, 'my_table_path')
add_constraints(spark_session=spark,
delta_table=mock_delta_table,
constraints={"name_is_not_null": "name is not null",
"age_higher_than_20": "age > 20"})
Remove constraint
To remove a constraint to a delta table:
from rezq import, remove_constraint
from delta import DeltaTable
delta_table = DeltaTable.forPath(spark, 'my_table_path')
remove_constraint(spark_session=spark,
delta_table=delta_table,
constraint_name='age_higher_than_20')
Get constraints
To get delta table constraints:
from rezq import, remove_constraint
from delta import DeltaTable
delta_table = DeltaTable.forPath(spark, 'my_table_path')
constraint = get_constraints(delta_table)
Get cleaned and quarantine
To return the cleaned_df (An DataFrame of the valid rows according to constraints) and quarantine_df (An DataFrame of the invalid rows according to constraints.):
from rezq import get_cleaned_and_quarantine
delta_table = DeltaTable.forPath(spark, 'mybucket')
cleaned_df, quarantine_df = get_cleaned_and_quarantine(delta_table=delta_table,
merge_df=df)
You can use the cleaned_df to create a new delta, append or merge to an existent one
and use quarantine_df to get metrics about data quality and decide later what to do
with this rows
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file rezq-0.1.4.tar.gz.
File metadata
- Download URL: rezq-0.1.4.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c9e5df018a011a20a00c53e96ae4d2fb1226d1dfe3670684e7cfcaeba7a7c73
|
|
| MD5 |
3c68beedcbf0b53df1c6e5eb9cd33192
|
|
| BLAKE2b-256 |
f99bcf4cb52f62995fab60d1a59b2fc89e96bae9400ca63ddc6bf86a711b197c
|