Replies: 11 comments 21 replies
|
This is great, thanks for working on this! |
|
@hy144328 what's the next step (or steps) here? Happy to help move things forward, we just might be able to land this in 7.0 if we're quick :D |
|
Didn't want to wait on this, so I dug into the actual checklist (the commented-out As it turns out, that env var is never actually set anywhere in CI, so none of this, including the 3 categories already "locked in", has ever been enforced automatically. #41915 fixes that. Also tried to knock out a few more categories that looked like free wins from a quick grep, but two of them ( @hy144328 does this line up with what you had in mind, or do you already have more of this in flight? Don't want to step on toes. |
|
THANK YOU VERY MUCH for doing this!! I'm a huge fan and a heavy user of Superset at my firm. However, IT dept is threatening to shut it down due to Superset's pin on Python 3.11, which only has 1 year left before reaching End Of Life. Apparently, being able to receive security patches is a big deal at my firm, and I'm sure many firms are in the same shoe. Apparently, the pin on 3.11 was mainly due to SqlAlchemy. So your work to bump SqlAlchemy to 2.0 is life-saving!!! |
|
Chipped away at three more of the cascade_backrefs cases: Query (#42210), SavedQuery (#42212), and SqlaTable (#42213). Turns out the callers were already adding everything to the session explicitly, so each one is just |
|
Maybe we should also add an item to the TODO list to bump all the SQLAlchemy drivers to the newer 2.0 compatible versions. It's basically follow-up work, but we might as well enumerate it. |
|
Approved #42277 but not sure if you want to fix the nit there before I merge it. |
|
#42542 merged and covers the driver dual-compat prep for step 6: bumped what could bump, and added I also tried the flask-sqlalchemy 3.0.5 bump in that same PR and had to revert it. Real CI turned up widespread NoneType errors across dashboards/security/tasks tests plus MySQL lock timeouts, capped below 3.0 for now. Dug into it more since, and I don't think it's our session handling at all, it's a gap in Flask-AppBuilder's own FSA-3.x shim: Also caught two more models missing So step 6's driver prep is done but the actual core bump is still blocked on the FAB gap getting resolved one way or another. [EDIT] Correction on the FAB theory from my last comment. Tested it directly in #42789 (draft, now closed), confirmed the registries actually do get unified with Pulled real failure logs this time instead of the summary. |
|
Status check on current The core bump is done and stable. #42803 (SQLAlchemy 2.0 + flask-sqlalchemy 3.1.1) merged 2026-08-13 and has held for 11 days since, including routine dependabot patch bumps (currently What's left, for anyone picking up loose ends: Upstream-blocked, nothing to do but track:
Small follow-ups:
Not blocking, but worth naming since "how far can we go" came up:
FAB: currently pinned Docs: Net: for the 7.0 release, this is done. What remains is either genuinely out of Superset's hands (upstream dialect support) or optional cleanup/modernization that doesn't need to gate anything. |
|
Follow-up on the punch list above — two more items closed out:
Remaining items are all upstream-blocked (aurora-data-api, d1, kusto, solr dialects with no 2.0 support on their end) — nothing actionable on Superset's side beyond tracking upstream. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I would like to propose a plan to migrate from SQLAlchemy 1.4 to 2.0.
From what I see in discussions, issues and PRs, we have not quite hit the homerun yet.
I already have some PRs in preparation, and I am interested in feedback.
Goals
Motivation
Personal motivation:
My company uses Superset with Dremio.
The SQLAlchemy plug-in for Dremio requires SQLAlchemy 2. https://github.com/narendrans/sqlalchemy_dremio/blob/c576c65318f58e9342bbdb3dd0d6d691af9299ba/setup.py#L12
Superset is still stuck at SQLAlchemy 1.
superset/pyproject.toml
Line 102 in 1230b90
Currently, we use a fork that forcefully downgrades the SQLAlchemy plug-in for Dremio.
However, this is not sustainable in the long term.
General motivation:
While SQLAlchemy has no official EOL dates, it is virtually there. sqlalchemy/sqlalchemy#13009
SQLAlchemy 2.0 has been out for multiple years now.
SQLAlchemy 2.1 is around the corner.
This will make SQLAlchemy obsolete.
Observations
SQLAlchemy 1.4 to 2.0 is a breaking change.
This includes both the direct dependency on SQLAlchemy and the indirect dependencies on other packages, e.g. Flask and Flask-SQLAlchemy.
There is a single-shot PR by @dpgaspar that attempts to bump everything in a single PR.
I am not sure whether the PR is ready.
The last commit is from September 2025.
The PR touches 92 files and over a thousand lines of code, which makes it a daunting task to review.
Therefore, I would like to suggest smaller steps to some pressure off before the final push of bumping the dependencies.
Firstly, SQLAlchemy 1.4 (current version) is already designed to be a transition version. https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#the-1-4-2-0-migration-path
This means that it enables in many cases both version 1 and 2 styles.
So we are able to update the code without actually bumping the SQLAlchemy version.
Secondly, SQLAlchemy is able to emit warnings.
This way, we are able to use the existing unit tests to check on the progress of the migration.
Thirdly, Python
warningsand PyTest integrate well with each other.So we are able to turn warning into errors, and mitigate regressions during collaboration.
Battleplan
Enable SQLAlchemy 1.4 deprecation warning in unit testing set-up.
After running all unit tests, I get the following warning cases:
This means that we are able to work on each warning case more or less independently:
as_declarative()function is now available chore: as_declarative() warnings are irrelevant #41982databasepackage is deprecated chore: sqlalchemy.database package warnings are irrelevant #41978declarative_base()function is now available refactor: import from sqlalchemy.orm #41981Use the
futureflag onEngine. https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-to-2-0-step-four-use-the-future-flag-on-engine refactor: engine enforce SQLAlchemy 2.0 #42277Use the
futureflag onSession. https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-to-2-0-step-five-use-the-future-flag-on-session chore: session enforce sqlalchemy 2.0 #42365Add
__allow_unmapped__to explicity typed ORM models. https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-to-2-0-step-six-add-allow-unmapped-to-explicitly-typed-orm-models refactor: make import/expression layer SQLAlchemy 2.0-compatible #41179Actually bump SQLAlchemy and indirect dependencies.
By then, chore: Support Flask 3.X and SQLAlchemy 2.X #35117 will hopefully have to do some less heavy lifting. :-)
Clean up the unit test set-up again.
Conclusion
As mentioned, I already have some PRs in mind, that I will add to the battleplan.
I do not see any downsides to the refactoring approach of incrementally mitigating the deprecation warnings before the actual bump (except boredom).
Curious to hear your thoughts.
All reactions