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

Expectations fail callback function #3

Closed
Casyfill opened this issue Nov 23, 2020 · 0 comments · Fixed by #4
Closed

Expectations fail callback function #3

Casyfill opened this issue Nov 23, 2020 · 0 comments · Fixed by #4
Labels
enhancement New feature or request

Comments

@Casyfill
Copy link
Contributor

It seems to be nice to be able to log out specific expectations that failed, when the Operator fails. I am not sure this should be internalized, so instead, perhaps it makes sense to set a callback function on fail?

I have something as naive as this in mind:

def generate_list_failed_expectations(r) -> str:
    """Note - only for validation results

    Input:
        r (reat_expectations.validation_operators.types.validation_operator_result.ValidationOperatorResult)
    Returns: str
    """
    from itertools import groupby

    lines = ["Validation with Great Expectations failed."]

    for batch, result in r["run_results"].items():
        lines.append(f"{batch}")
        failed = [
            r.expectation_config
            for r in result["validation_result"].results
            if not r.success
        ]
        for col, group_failed in groupby(failed, key=lambda k: k["kwargs"]["column"]):
            lines.append(f"  {col}")
            for test in group_failed:
                lines.append(f'    - {test["expectation_type"]}')
    raise AirflowException("\n".join(lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants