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

[MAINTENANCE] Helpful Message for Expectations that require Metrics that are not available #8906

Merged
merged 14 commits into from Nov 6, 2023

Conversation

Shinnnyshinshin
Copy link
Contributor

@Shinnnyshinshin Shinnnyshinshin commented Nov 1, 2023

Currently, if an Expectation is misconfigured (such as referencing a non-existent column name), we get a cryptic error message.

    provided_metrics: Dict[str, MetricValue] = {
>       metric_name: metrics[metric_configuration.id]
        for metric_name, metric_configuration in validation_dependencies.metric_configurations.items()
    }
E   KeyError: ('column_values.nonnull.unexpected_count', '9fb963653447edb4ae8538917d6915bc', ())

This PR adds a check in expectation.py, where we validate dependencies of the current Expectation against available metrics, and outputs a more helpful error message:

An error message will look something like this:

great_expectations.exceptions.exceptions.InvalidExpectationConfigurationError: Metric ('table.row_count', '7054e9d72e974fad769b0964f41e7e5b', "result_format={'result_format': 'BASIC', 'partial_unexpected_count': 20, 'include_unexpected_rows': False}") is not available for validation of {
                 "expectation_type": "expect_column_values_to_not_be_null",
                 "kwargs": {
                   "column": "I_dont_exist",
                   "batch_id": "projects-projects"
                 },
                 "meta": {}
              }. Please check your configuration.
  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses black + ruff)
  • Appropriate tests and docs have been updated

Copy link

netlify bot commented Nov 1, 2023

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit 0e93670
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/654564df3bdcde0008a6e759

@Shinnnyshinshin Shinnnyshinshin self-assigned this Nov 1, 2023
@Shinnnyshinshin Shinnnyshinshin marked this pull request as draft November 1, 2023 00:18
@ghost
Copy link

ghost commented Nov 1, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@Shinnnyshinshin Shinnnyshinshin changed the title [MAINTENANCE] Helpful Message for Expectations that require non-available Metrics [MAINTENANCE] Helpful Message for Expectations that require Metrics that are not available Nov 1, 2023
* develop:
  [DOCS] add 'user' access token clarification to GX Cloud quickstart (#8912)
  [MAINTENANCE] Typing render/view  (#8903)
  [MAINTENANCE] Adjust timeouts for cloud-tests services (#8910)
  [DOCS] Update Section Title (#8905)
@Shinnnyshinshin Shinnnyshinshin marked this pull request as ready for review November 1, 2023 21:26
@Shinnnyshinshin Shinnnyshinshin requested a review from a team November 2, 2023 00:17
@JennyTee
Copy link
Contributor

JennyTee commented Nov 2, 2023

I like the extra error message; that seems much more helpful. Is this the only fix needed for #8619, then? Does this mean that for databases with case-insensitive column names, GX users will need to define expectations with case-sensitive column names?

Copy link
Member

@anthonyburdi anthonyburdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - just wondering about the pythonsqlite.db-journal file added. Could you clarify why that was added?

]


def fake_expectation_config(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good names make things so much easier ❤️ Thank you for refactoring this.

Copy link
Member

@anthonyburdi anthonyburdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful error message, thanks for this PR!

@Shinnnyshinshin Shinnnyshinshin added this pull request to the merge queue Nov 6, 2023
Merged via the queue into develop with commit 2fb5aa8 Nov 6, 2023
58 checks passed
@Shinnnyshinshin Shinnnyshinshin deleted the m/zel-164/better-messaging-validator branch November 6, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants