-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Allow Legacy SqlSensor to use the common.sql providers #25293
Allow Legacy SqlSensor to use the common.sql providers #25293
Conversation
This is a very interesting and originally unforeseen effect of common.sql provider separation, It's hard to test it with unit tests, because you actually you need install Airflow 2.3 or below to test it (so the tests that I added are not actually testing what you might think they are) But I tested it manually:
Then I repeated what "SqlSensor" does from Airflow 2.3.3: After this change when common.sql DbApiHook is installed on Airlfow 2.4+ it inherits from BaseHook, but when installed in Airlfow 2.3, it inherits from airflow.hooks.dbapi.DbApiHook (it overrides all the legacy hook methods so this has virtually no side effect). This allows the |
22b873d
to
560d334
Compare
NVM missread the description |
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.
mmm what about BranchSqlOperator?
I would expect it to have the same issue.
Or we didn't move it from core to the provider yet?
Actually ... yeah. We haven't moved them yet :).. This is a good point that we should have ... But the change will work fine for all kinds of combinations :). |
560d334
to
e798a60
Compare
PR here #24836 |
Maybe instead of importing the deprecated base class, we should do different things depending on Airflow version:
This would avoid needing the |
Yeah. I was wondering if it's not too much of a hack myself. I think we already use version check in a number of places and I agree using it here might be a better idea (I also do not know performance implications of the circular import detection ). |
I will need #25299 before we merge this one, otherwise we have far too many mypy problems to solve (and it is good for upcoming unification of methods in common.sql). |
e798a60
to
2ff791c
Compare
2ff791c
to
0f6c296
Compare
Rebased on top of #25299 so only last commit (very small) matters |
e5bd9aa
to
058ae19
Compare
058ae19
to
40d732e
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.
About the one commit specifically.
The legacy Airflow SqlSensor, rejects working wiht comon.sql providers eve if they are perfectly fine to use. While users could switch to the common.sql sensor (and it should work fine). we should not force the users to switch to it. We are implementing "fake" class hierarchy in case the provider is installed on Airflow 2.3 and below. In case of Airflow 2.4+ importing the old DbApiHook will fail, because it will cause a circular import - in such case our new DbApiHook will derive (as it was originally planned) from BaseHook. But In case of Airflow 2.3 and below such import will succeed and we are using the original DbApiHook from airflow.hooks.dbapi as base class - this way any "common.sql" hook on Airflow 2.3 and below will also derive from the airlfow.hooks.dbapi.DbApiHook - thus it will be possible to use it by the original SqlSensor. Fixes: apache#25274
40d732e
to
3b44a7f
Compare
Yep. Previous merged already. |
The legacy Airflow SqlSensor, rejects working wiht comon.sql providers
eve if they are perfectly fine to use.
While users could switch to the common.sql sensor (and it
should work fine). we should not force the users to switch to it.
We are implementing "fake" class hierarchy in case the provider
is installed on Airflow 2.3 and below.
In case of Airflow 2.4+ importing the old DbApiHook will fail,
because it will cause a circular import - in such case our
new DbApiHook will derive (as it was originally planned) from
BaseHook.
But In case of Airflow 2.3 and below such import will succeed
and we are using the original DbApiHook from airflow.hooks.dbapi
as base class - this way any "common.sql" hook on Airflow 2.3
and below will also derive from the airlfow.hooks.dbapi.DbApiHook
Fixes: #25274
^ 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.