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

DONT APPROVE BEFORE 55! 0.9.9.1 - test_overwrite per column instead of model and fk at_least_one #57

Merged
Merged
Show file tree
Hide file tree
Changes from 9 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
Binary file added droughty/dist/droughty-0.9.4-py3-none-any.whl
Binary file not shown.
Binary file added droughty/dist/droughty-0.9.4.tar.gz
Binary file not shown.
Binary file added droughty/dist/droughty-0.9.5-py3-none-any.whl
Binary file not shown.
Binary file added droughty/dist/droughty-0.9.5.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions droughty/droughty/droughty_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def assign_explore_variables():

explores = (droughty_project.get("explores"))
ExploresVariables.explore_tables = (droughty_project.get("explores"))
ExploresVariables.dbml_schemas = (droughty_project.get("dbml_schemas"))
ExploresVariables.dbml_schemas = (droughty_profile[value]['dbml_schemas'])

ExploresVariables.lookml_path = (droughty_project.get("lookml_path"))
ExploresVariables.dbml_path = (droughty_project.get("dbml_path"))
Expand Down Expand Up @@ -291,7 +291,7 @@ def assign_explore_variables():
except:
ExploresVariables.test_ignore = "None"
try:
ExploresVariables.test_schemas = droughty_project['test_schemas']
ExploresVariables.test_schemas = droughty_profile[value]['test_schemas']
except:
ExploresVariables.test_schemas = "None"
try:
Expand Down
116 changes: 57 additions & 59 deletions droughty/droughty/droughty_dbt/dbt_test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@
import git


def get_all_values(nested_dictionary,test_overwrite_dictionary):
def get_all_values(nested_dictionary):

test_overwrite = ExploresVariables.test_overwrite

try:

if test_overwrite != None:

nested_dictionary.update(test_overwrite_dictionary)
ignore_test_keys_and_values = []

ignore_test_keys = list(ExploresVariables.test_overwrite.keys())
for key, value in test_overwrite.items():

nested_dictionary[key].update(value)

for sub_key in value.keys():
ignore_test_keys_and_values.append(key + "-" + sub_key)

else:

Expand All @@ -47,83 +52,77 @@ def get_all_values(nested_dictionary,test_overwrite_dictionary):
res = [{"version":2},{"models":None}]

for key,value in nested_dictionary.items():

if key not in ignore_test_keys and not key in ExploresVariables.test_ignore:


seq = []
res.append([{"name": key, "columns": seq}])
# for key1, value1 in value.items(): # not using value1

for key1,value1 in value.items():

if key1 in described_columns_list:

if "pk" in key1 and "not_null" not in value1 and "unique" not in value1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["not_null","unique"]}
seq.append(elem)

elif "fk" in key1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["not_null"]}
seq.append(elem)

elif "valid_to" in key1 or "valid_from" in key1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["dbt_utils.expression_is_true"":""expression"":"" valid_from < valid_to","not_null","unique"]}
seq.append(elem)

elif "pk" not in key1 or "fk" not in key1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": [""+"dbt_utils.at_least_one"]}
seq.append(elem)

elif "pk" not in key1 or "fk" not in key1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}"}
seq.append(elem)
if key + "-" + key1 not in ignore_test_keys_and_values and not key in ExploresVariables.test_ignore:

elif key1 not in described_columns_list:
if key1 in described_columns_list:

if "pk" in key1:
if "pk" in key1 and "not_null" not in value1 and "unique" not in value1:

elem = {"name": key1, "tests": ["not_null","unique"]}
elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["not_null","unique"]}
seq.append(elem)

elif "fk" in key1:

elem = {"name": key1, "tests": ["not_null"]}
elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["dbt_utils.at_least_one"]}
seq.append(elem)

elif "valid_to" in key1 or "valid_from" in key1:

elem = {"name": key1, "tests": ["dbt_utils.expression_is_true"":""expression"":"" valid_from < valid_to","not_null","unique"]}
elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": ["dbt_utils.expression_is_true"":""expression"":"" valid_from < valid_to","not_null","unique"]}
seq.append(elem)

elif "pk" not in key1 or "fk" not in key1:

elem = {"name": key1, "tests": [""+"dbt_utils.at_least_one"]}
seq.append(elem)

elif key in ignore_test_keys and key not in ExploresVariables.test_ignore:
elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": [""+"dbt_utils.at_least_one"]}
seq.append(elem)

seq = []
res.append([{"name": key, "columns": seq}])
# for key1, value1 in value.items(): # not using value1
elif "pk" not in key1 or "fk" not in key1:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}"}
seq.append(elem)

for key1,value1 in value.items():
elif key1 not in described_columns_list:

if "pk" in key1:

elem = {"name": key1, "tests": ["not_null","unique"]}
seq.append(elem)

elif "fk" in key1:

elem = {"name": key1, "tests": ["dbt_utils.at_least_one"]}
seq.append(elem)

elif "valid_to" in key1 or "valid_from" in key1:

elem = {"name": key1, "tests": ["dbt_utils.expression_is_true"":""expression"":"" valid_from < valid_to","not_null","unique"]}
seq.append(elem)

elif "pk" not in key1 or "fk" not in key1:

elem = {"name": key1, "tests": [""+"dbt_utils.at_least_one"]}
seq.append(elem)

elif key + "-" + key1 in ignore_test_keys_and_values and key not in ExploresVariables.test_ignore:

if key1 in described_columns_list:

if key1 in described_columns_list:

elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": value1}
seq.append(elem)


elem = {"name": key1, "description": "{{doc("+'"'+key1+'"'+")}}", "tests": value1}
seq.append(elem)
elif key1 not in described_columns_list:

elif key1 not in described_columns_list:
elem = {"name": key1, "tests": value1}
seq.append(elem)

res.append([{"name": key, "columns": seq}])

elem = {"name": key1, "tests": value1}
seq.append(elem)

return res

def schema_output():
Expand Down Expand Up @@ -159,8 +158,7 @@ def schema_output():

with redirect_stdout(file):

for i in get_all_values(dbt_test_dict(),ExploresVariables.test_overwrite):

for i in get_all_values(dbt_test_dict()):
yaml = ruamel.yaml.YAML()
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.dump(i,file)
yaml.indent(mapping=2, sequence=4, offset=2)
yaml.dump(i,file)
4 changes: 2 additions & 2 deletions droughty/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "droughty"
version = "0.9.3"
version = "0.9.5"
description = "droughty is an analytics engineering toolkit, helping keep your workflow dry."
authors = ["Lewis <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -31,7 +31,7 @@ tqdm = "4.62.3"
Markdown = "^3.3.6"
Jinja2 = "3.0.1"
glom = "^22.1.0"
pyarrow = "6.0.0"
pyarrow = "8.0.0"
openai = "^0.25.0"

[tool.poetry.scripts]
Expand Down