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

[BUGFIX] Use one inspector for the same engine/execution_engine #8534

Merged

Conversation

TrangPham
Copy link
Contributor

@TrangPham TrangPham commented Aug 10, 2023

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

  • 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

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!

@github-actions github-actions bot added the core label Aug 10, 2023
@TrangPham TrangPham requested a review from a team August 10, 2023 23:59
@ghost
Copy link

ghost commented Aug 11, 2023

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

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@netlify
Copy link

netlify bot commented Aug 11, 2023

Deploy Preview for niobium-lead-7998 ready!

Name Link
🔨 Latest commit dd3ae43
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/6500ca2c119870000809f3f6
😎 Deploy Preview https://deploy-preview-8534.docs.greatexpectations.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@TrangPham TrangPham marked this pull request as draft August 11, 2023 00:05
@TrangPham TrangPham marked this pull request as ready for review August 12, 2023 01:19
@TrangPham TrangPham requested a review from Kilo59 August 12, 2023 01:19
Comment on lines +90 to +92
def _get_sqlalchemy_column_metadata(
execution_engine: SqlAlchemyExecutionEngine, batch_data: SqlAlchemyBatchData
):
Copy link
Member

@Kilo59 Kilo59 Aug 23, 2023

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 😄

Copy link
Contributor Author

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:

Comment on lines 55 to 56
@pytest.mark.sqlite
def test_table_column_type__sqlalchemy_happy_path(sa, capfd):
Copy link
Contributor

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?

Copy link
Contributor Author

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

@TrangPham
Copy link
Contributor Author

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.

Comment on lines +156 to +158
# Should have to re-inspect due to new batch
# But should use same inspector
assert mock_inspect.call_count == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@Shinnnyshinshin Shinnnyshinshin left a 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

@TrangPham TrangPham merged commit d3ffeb3 into develop Sep 12, 2023
57 checks passed
@TrangPham TrangPham deleted the DX-60-clone-issue-5933-bug-snowflake-metadata-is-not-caching branch September 12, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Snowflake metadata is not caching
3 participants