-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[DOCS] fix custom SQL Expectation approach for cloud #10844
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
❌ 5 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
…/great_expectations into kml/DOC-941/customSQL
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
``` | ||
|
||
2. Override the Expectation's `unexpected_rows_query` attribute. | ||
1. Determine your custom SQL query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewers: I re-flowed the instructions to be more like the create an Expectation page where you determine parameters and then create an Expectation using them because the snippets were ending in awkward places when I tried to keep the old flow while switching from subclassing to using the class directly. Example of one iteration I didn't like:
ExpectPassengerCountToBeLegal = gx.expectations.UnexpectedRowsExpectation( | ||
unexpected_rows_query=my_query, description=my_description | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewers: I wanted the parameters to be on separate lines, but a CI automation keeps shoving them into one combined line. Is there any way I can preserve the line break?
ExpectPassengerCountToBeLegal = gx.expectations.UnexpectedRowsExpectation(
unexpected_rows_query = my_query,
description = my_description
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, you can just throw a trailing comma after my_description
. AFAIK ruff format
uses black
, which is pretty opinionated, and that's one of its demands.
In other cases, if you really need an escape hatch, you can tell the formatter to skip a section with a # fmt: off
and then a # fmt: on
where it should start again. Looks like we only use that in one other place in this repo; I'd be extremely judicious in using this. The philosophy is pretty much to just go with what the formatter says, even if you don't love it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Left one small blocker on naming conventions!
ExpectPassengerCountToBeLegal = gx.expectations.UnexpectedRowsExpectation( | ||
unexpected_rows_query=my_query, description=my_description | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, you can just throw a trailing comma after my_description
. AFAIK ruff format
uses black
, which is pretty opinionated, and that's one of its demands.
In other cases, if you really need an escape hatch, you can tell the formatter to skip a section with a # fmt: off
and then a # fmt: on
where it should start again. Looks like we only use that in one other place in this repo; I'd be extremely judicious in using this. The philosophy is pretty much to just go with what the formatter says, even if you don't love it.
|
||
# Customize how the Expectation renders in Data Docs. | ||
# <snippet name="docs/docusaurus/docs/core/customize_expectations/_examples/use_sql_to_define_a_custom_expectation.py - define description"> | ||
my_description = "There should be no more than **6** passengers." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't take action on this now, but just throwing it out as a stylistic thing in case other folks feel similarly - I personally find it much more to take in when we spread out simple stuff across multiple snippets, i.e., I'd rather just see this inlined when creating the expectation. But again, that's just my 2 cents!
|
||
# Create an Expectation using the UnexpectedRowsExpectation class and your parameters. | ||
# <snippet name="docs/docusaurus/docs/core/customize_expectations/_examples/use_sql_to_define_a_custom_expectation.py - create Expectation"> | ||
ExpectPassengerCountToBeLegal = gx.expectations.UnexpectedRowsExpectation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so small, but I'm going to throw a blocker on it. ExpectPassengerCountToBeLegal
follows the class-naming convention. This should be expect_passenger_count_to_be_legal
or something like that in snake_case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Resolves https://greatexpectations.atlassian.net/browse/DOC-941
invoke lint
(usesruff format
+ruff check
)@netlify /docs/core/customize_expectations/use_sql_to_define_a_custom_expectation/
For more information about contributing, visit our community resources.
After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!