Update code style for airflow db commands to SQLAlchemy 2.0 style#31486
Conversation
|
Hmm, db init is failing with But |
9619d4b to
d5943f4
Compare
It should be fine now. I think I went overboard and used the metadata we use in creating DB models to reflect tables |
d5943f4 to
43d43cb
Compare
be4a85a to
fdeaf05
Compare
fdeaf05 to
f7bef4f
Compare
There was a problem hiding this comment.
Is the bind=bind part still needed? You already set metadata.bind above.
There was a problem hiding this comment.
Yeah. It was surprising to me too. Here's the warning that it throws:
/opt/airflow/airflow/utils/db.py:1023 RemovedIn20Warning: The ``bind`` argument for schema methods that invoke SQL against an engine or connection will be required in SQLAlchemy 2.0. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
There was a problem hiding this comment.
Do we need the metadata.bind line also then? Seems odd to need both.
There was a problem hiding this comment.
Have removed it. I remember having some issues around the metadata but let's see if the CI passes cause I can't reproduce locally
There was a problem hiding this comment.
Here's the error https://github.com/apache/airflow/actions/runs/5083011128/jobs/9133579355?pr=31486#step:5:10813, adding the bind back...
There was a problem hiding this comment.
What happened was that the metadata that was returned by the function was not bound to any database. The other binds are for the reflect methods. Despite the session being bound to metadata, they still want the bind to happen on its method
There was a problem hiding this comment.
Maybe instead we can add bind=bind explicitly to the method calls instead? Not sure how feasible that is without actually digging into the call stack.
There was a problem hiding this comment.
Seeing this now...taking a look
There was a problem hiding this comment.
Do we need the metadata.bind line also then? Seems odd to need both.
35991d5 to
c2423ca
Compare
|
Please don't merge yet, investigating MSSQL failure locally(it's canceled on CI) |
c2423ca to
98643ee
Compare
Resolved: 98643ee |
This commit introduces changes to the code styles of `airflow db` commands to remove 'RemovedIn20Warning' and ensure compatibility with SQLAlchemy 2.0. To see these warnings, you need to set SQLALCHEMY_WARN_20=True when using the db commands
98643ee to
edbbb7e
Compare
This commit introduces changes to the code styles of
airflow dbcommands to remove 'RemovedIn20Warning' and ensure compatibility with SQLAlchemy 2.0.To see these warnings, you need to set SQLALCHEMY_WARN_20=True when using the db commands
Part of #28723