-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
fix: catalog upgrade/downgrade #29780
Conversation
6868b9f
to
5437d0e
Compare
# more than 50 different database drivers. Usually the try/except block will catch the | ||
# generic `Exception` class, which requires a pylint disablee comment. To make it clear | ||
# that we know this is a necessary evil we create an alias, and catch it instead. | ||
GenericDBException = Exception |
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.
why not ->
class GenericDBException(Exception):
pass
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.
nevermind, I understand now reading the code
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 that case the exceptions from all the DB API drivers would not be derived from GenericDBException
, so we wouldn't be able to catch them.
The only exception that is a parent to all the exceptions from the multitude of DB API drivers we support is Exception
itself (I hope!), which is why we have to write:
try:
# do something with some dynamically loaded DB API driver
except Exception: # pylint: disable=broad-except
pass
It's inevitable to have a broad except, because the drivers are loaded dynamically. My alias is just a way of saying "I know this is bad, but what can I do?", but also "I'm expecting an exception here that could be anything".
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.
I did a pass on this and overall LGTM
@supersetbot label 4.1 |
(cherry picked from commit 525e837)
(cherry picked from commit 525e837)
(cherry picked from commit 525e837)
SUMMARY
Many little improvements to the catalog migration helpers, especially on the downgrade.
The exception to (1) is that on
upgrade
we need to rundatabase.get_default_catalog()
in order to update models; doing this later would be messy and could lead to security issues. Theget_default_catalog()
method usually doesn't need to connect to the analytical database, except for Databricks (where it's always the need) and BigQuery (when the project is not specified in the SQLAlchemy URI).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Updated and improved tests.
ADDITIONAL INFORMATION