Fix overwrite get_uri for Trino - #48917
Conversation
get-uri for Trinoget_uri for Trino
jason810496
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I left a question regarding whether we really need to override get_uri for TrinoHook, as it seems there’s no special case for it.
jason810496
left a comment
There was a problem hiding this comment.
Maybe we could consider implementing a more generic
get_uriinDbApiHook.
Yes, indeed. We can create another PR after this one to introduce some private methods in DbApiHook.
( it's fine to have duplicate code in the current one, not to make the scope too large )
For example, comparing the previous MySQL implementation and the current Trino one, we have duplicated logic in:
uri_prefixauth_parthost_partschema_part- URI concatenation
- extra connection parameters
The DbApiHook.get_uri could leverage these private methods to build the final URI.
We could define private methods for each of these duplicated parts, and allow providers to override only what’s necessary for special cases.
For instance, Trino would only need to override _get_schema_part, MySQL only need to override _get_uri_prefix part.
|
Thanks for looking into this issue and suggestion! It does make sense, to implement common private functions do help reduce code duplicate issue. I would try to open another PR to implement some private func in |
0bc24c2 to
bcecb31
Compare
jason810496
left a comment
There was a problem hiding this comment.
After clearing the context, the PR looks good to me, thanks!
|
Thanks! |
bcecb31 to
125df75
Compare
125df75 to
74bcc84
Compare
|
CC @eladkal @jason810496 do you think this one's good to land? |
Sure, LGTM to include in current provider release. |
get_uri for Trinoget_uri for Trino
Related Issue
Towards #38195
Why
DbApiHook's
get_uri()incorrectly assumes Airflow Connection URIs are valid SQLAlchemy URIs, which fails in complex cases, especially with special characters. ForTrino, the connection URI requires proper URL encoding and specific handling of catalog/schema information.This PR implements a robust
get_uri()method inTrinoHookthat correctly formatsTrinoconnection URIs with proper URL encoding of special characters.How
get_uri()inTrinoHookwith proper URLreference: https://github.com/trinodb/trino-python-client?tab=readme-ov-file
^ 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.