-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Add oracledb thick mode support for oracle provider #26576
Conversation
Some errors :( |
@potiuk Not related to my changes but I'll keep updating from main until resolved. |
3ddc51a
to
a7d14b3
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.
you are duplicating some code from get_conn
get_conn
is by convention the method you call to get the client. can you update that code instead of adding a separate client creation path?
@dstandish Apologies - I took @potiuk 's comments on #24618 to mean it should go in the |
doesn't really matter. call it client generation / construction / auth / whathaveyou... in any case why retrieve the conn in two places, in two different ways? if you do it in what's the difference between the way we handle the airflow conn in init vs in get_conn? probably there shouldn't be any difference, because probably it should just be done once and in one place right? |
looks like you're referring to this comment. he's suggesting adding another param but not necessarily suggesting add more airflow conn retrieval. you can store the mode param as an instance attr and look at it in get_conn. |
@dstandish Do you mean just move the connection retrieval to the |
c2b2d6a
to
df7fbde
Compare
@dstandish Let me know if my most recent commit is more in line with what you were thinking. Tests passed locally but we'll see how the full suite goes. |
26bf754
to
6416c16
Compare
@@ -82,6 +102,7 @@ def test_get_conn_sid(self, mock_connect): | |||
def test_get_conn_service_name(self, mock_connect): | |||
dsn_service_name = {'dsn': 'ignored', 'service_name': 'service_name'} | |||
self.connection.extra = json.dumps(dsn_service_name) | |||
self.db_hook.__init__() |
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.
seems you should not have to do this?
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 because of the way the tests were originally structured. They create the hook in setUp
(line 64 in my commit) and then modify the extra in the tests themselves. Since all the parameter parsing is now happening in the __init__
it never picks that up. This seemed to work for picking up those changes without drastically changing the tests. I considered trying to rework it to function more like the way tests are structured in https://github.com/apache/airflow/blob/main/tests/providers/ssh/hooks/test_ssh.py with a separate connection for each variation. But I'm not very confident in writing tests in the first place and didn't fully understand how to rewrite all this in that way.
I did feel a little goofy doing it this way but it seemed to work for the purpose just fine and I couldn't think of any negatives aside from it just being goofy.
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.
right so the code before, it retrieved the airflow conn object and recreated the client object every time get_conn was called.
and then they changed the airflow conn object resulting in different behavior with client creation time. and your move of the logic to __init__
changes this behavior, so that get_conn doesn't re-retrieve the object.
while it's strictly speaking a "breaking" change probably it's unlikely to trip anyone up. but i think it would be best to adjust the tests so that the code is invoked in a more normal way.
what you could is apply mock.patch decorator to patch the get_connection
method (instead of doing it by assignment in setUp) and then set it to return the modified conn object, then instantiate your hook in each test method e.g. db_hook = OracleHook(...)
.
So you have done quite a bit of refactoring, and added, it seems, quite a bit of new functionality, but you have only added a test for the thick mode part. In writing hooks, particularly when you need to reconcile information between hook params and airflow conn attrs (which might both be supplied), it's generally desired to test that behavior to verify that you resolve it properly and what the order of precedence is. What I would like to suggest is, just keep this PR confined to adding thick mode support. And do it as I suggested before, by adding a parameter or two to |
@dstandish I don't understand how I'd add the parameters to check for the thick_mode stuff to init without duplicating the get_connection stuff. Why not just add it in |
19720d4
to
49219f0
Compare
03397f4
to
d7c43e0
Compare
05b1880
to
f289982
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.
Looks good! Just a small question on aligning default values of boolean parameters as mentioned in docstrings and docs.
20b2f86
to
ba89fa4
Compare
ba89fa4
to
b1052a6
Compare
…faults if provided
b1052a6
to
df99481
Compare
closes: #24618
Adds support for oracledb thick mode in the oracle provider, along with the option to set some defaults supported by oracledb (fetch_decimals and fetch_lobs).