-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Dynamic import MySqlHook/PostgresHook in CloudSQLDatabaseHook #41009
Dynamic import MySqlHook/PostgresHook in CloudSQLDatabaseHook #41009
Conversation
c978cc1
to
74548fd
Compare
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.
Changes look good, but what's the reason for placing imports inside methods? Could we just keep them on the top?
74548fd
to
8113c00
Compare
@moiseenkov Thank you for reviewing! The issue #40175 : ModuleNotFoundError ( By placing the module import inside the method, we ensure that the module is imported only when it is actually needed, thereby avoiding the import error when the module is not required. The first screenshot shows what happens when the import is placed at the top, without the mysql module. The second screenshot shows what happens when the import is placed inside the method. |
8113c00
to
77f2246
Compare
77f2246
to
3d9f4a3
Compare
3d9f4a3
to
194d596
Compare
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.
Welcome to Apache AIrflow, it looks good!
I got a small question before merging :)
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
closes: #40175
CloudSQLDatabaseHook: Dynamic imports MySqlHook/PostgresHook within get_database_hook method
Changes:
PostgresHook | MySqlHook
toBaseHook
.^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.