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
[BUGFIX] Use one inspector for the same engine/execution_engine #8534
[BUGFIX] Use one inspector for the same engine/execution_engine #8534
Conversation
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…data-is-not-caching
def _get_sqlalchemy_column_metadata( | ||
execution_engine: SqlAlchemyExecutionEngine, batch_data: SqlAlchemyBatchData | ||
): |
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.
Sorry for the late review.
@TrangPham are you sure this is meant to be the SqlAlchemyExecutionEngine
and not just the native Sqlalchemy sqlachemy.engine,Engine
type?
A type annotation here would have been helpful 😄
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.
Yes this is correct. It is being called in one place in this function which passes in the execution engine:
great_expectations/great_expectations/expectations/metrics/table_metrics/table_column_types.py
Line 46 in 4c13026
execution_engine: SqlAlchemyExecutionEngine, |
…data-is-not-caching
…data-is-not-caching
@pytest.mark.sqlite | ||
def test_table_column_type__sqlalchemy_happy_path(sa, capfd): |
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.
Curious : were you able to get this test passing locally?
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.
Yes this passes locally for me
…data-is-not-caching
…data-is-not-caching
…data-is-not-caching
Updated the tests so it would work. Seems like it passed for me locally, but within the github ci the sqlite file was being closed and capsys.readerrout().err was showing that the file was closed when trying to run empty SQL. This is for the happy path with used our metric resolution directly vs the other test which calls get_column without going through the metric resolution. |
# Should have to re-inspect due to new batch | ||
# But should use same inspector | ||
assert mock_inspect.call_count == 1 |
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.
🚀
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.
LGTM! Thank you for this @TrangPham
…data-is-not-caching
Previously, we were getting a new inspector each time that "table.column_types" metric was being computed. This means that SQLAlchemy would not see that information as cached as it is for a different inspector instance.
This changes adds _inspector to the ExecutionEngine and uses that same inspector later on (making it a singleton-ish).
Some additional refactoring can be done to move the functionality of "get_column_metadata" into the different engines and just ask the engine for that information. This would mean a refactor of the functions that "table_column_types.py" uses.
Closes: #5933
invoke lint
(usesblack
+ruff
)For more information about contributing, see Contribute.
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!