Fix overwrite get-uri for MySQL#48706
Merged
Merged
Conversation
guan404ming
force-pushed
the
add-get-uri-for-mysql
branch
from
April 2, 2025 18:28
8f675aa to
f2c55a2
Compare
get-uri for MySQLget-uri for MySQL
get-uri for MySQLget-uri for MySQL
jason810496
reviewed
Apr 3, 2025
jason810496
left a comment
Member
There was a problem hiding this comment.
Looks good in general, left some nits for test cases.
Co-Authored-By: LIU ZHE YOU <68415893+jason810496@users.noreply.github.com>
Member
Author
|
Updated, thanks for reviewing~ |
jason810496
reviewed
Apr 4, 2025
jason810496
left a comment
Member
There was a problem hiding this comment.
Thanks for the update. I left a few suggestions regarding test conventions.
Lee-W
reviewed
Apr 4, 2025
Co-authored-by: Wei Lee <weilee.rx@gmail.com>
Member
Author
|
Thanks a lots for reviewing, I had learned the convention more and updated with your comments! |
jason810496
approved these changes
Apr 7, 2025
Lee-W
approved these changes
Apr 8, 2025
simonprydden
pushed a commit
to simonprydden/airflow
that referenced
this pull request
Apr 8, 2025
* feat: overwrite `get-uri` for MySQL * refactor: refine `get_uri` and unit test Co-Authored-By: LIU ZHE YOU <68415893+jason810496@users.noreply.github.com> * refactor: using `pytest.param` with the `id` * refactor: apply suggestions from code review Co-authored-by: Wei Lee <weilee.rx@gmail.com> * refactor: use `urlencode` to add extra --------- Co-authored-by: LIU ZHE YOU <68415893+jason810496@users.noreply.github.com> Co-authored-by: Wei Lee <weilee.rx@gmail.com>
get-uri for MySQLget-uri for MySQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Towards #38195
Why
The base
DbApiHook.get_uriincorrectly assumes the Airflow connection URI (Connection.get_uri()) is a valid database-specific URI. This often fails, especially for MySQL which supports multiple drivers (mysqlclient,mysql-connector-python) requiring different URI schemes and needs proper handling of special characters in credentials, schema, or parameters.This override provides a correct, MySQL-specific implementation, fixing connection issues caused by improperly formatted or encoded URIs generated by the base method.
How
DbApiHook.get_urimethod withinMySqlHook.mysql://ormysql+mysqlconnector://) based on theclientfield in the connection'sextraparameters.urllib.parse.quote_plusto correctly URL-encode the username, password, schema, and any other parameters passed viaextra.extra.^ 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.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.