Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update input_helpers.py #20

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dq-suite-amsterdam"
version = "0.5.2"
version = "0.5.3"
authors = [
{ name="Arthur Kordes", email="a.kordes@amsterdam.nl" },
{ name="Aysegul Cayir Aydar", email="a.cayiraydar@amsterdam.nl" }
Expand Down
20 changes: 20 additions & 0 deletions src/dq_suite/input_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ def export_schema(dataset: str, spark: SparkSession):


def fetch_schema_from_github(dq_rules):
"""
Function fetches a schema from the Github Amsterdam schema using the dq_rules.

:param dq_rules: A dictionary with all DQ configuration.
:type dq_rules: dict
:return: schemas: A dictionary with the schema of the required tables.
:rtype: dict
"""

schemas = {}
for table in dq_rules['tables']:
if 'validate_table_schema_url' in table:
Expand All @@ -108,6 +117,17 @@ def fetch_schema_from_github(dq_rules):


def generate_dq_rules_from_schema(dq_rules: dict, schemas: dict) -> dict:
"""
Function adds expect_column_values_to_be_of_type rule for each column of tables having schema_id and schema_url in dq_rules.

:param dq_rules: A dictionary with all DQ configuration.
:type dq_rules: dict
:param schemas: A dictionary with the schemas of the required tables.
: type: dict
:return: dq_rules: A dictionary with all DQ configuration.
:rtype: dict
"""

for table in dq_rules['tables']:
if 'validate_table_schema' in table:
schema_id = table['validate_table_schema']
Expand Down