You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/07/16 17:31:30 UTC

(superset) branch master updated: refactor: automatically load with engine/connection (#41980)

This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 661535e3909 refactor: automatically load with engine/connection (#41980)
661535e3909 is described below

commit 661535e39099d9fe1adfa27c8f95762be651836c
Author: Hans Yu <ha...@outlook.de>
AuthorDate: Thu Jul 16 19:31:23 2026 +0200

    refactor: automatically load with engine/connection (#41980)
    
    Co-authored-by: Evan Rusackas <ev...@preset.io>
---
 pytest.ini                                                        | 3 +--
 superset/extensions/metadb.py                                     | 1 -
 .../2020-01-08_01-17_e96dbf2cfef0_datasource_cluster_fk.py        | 8 ++++----
 ...-04-24_10-46_e557699a813e_add_tables_relation_to_row_level_.py | 8 ++++----
 ...-15_18-22_e5ef6828ac4e_add_rls_filter_type_and_grouping_key.py | 2 +-
 superset/models/core.py                                           | 1 -
 superset/utils/core.py                                            | 4 +---
 7 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/pytest.ini b/pytest.ini
index 38c2c505731..1a4054f036b 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -35,8 +35,7 @@ filterwarnings =
 #    error:"SqlMetric" object is being merged into a Session:sqlalchemy.exc.RemovedIn20Warning
 #    error:"TableColumn" object is being merged into a Session:sqlalchemy.exc.RemovedIn20Warning
 #    error:"TaggedObject" object is being merged into a Session:sqlalchemy.exc.RemovedIn20Warning
-#    error:The autoload parameter is deprecated:sqlalchemy.exc.RemovedIn20Warning
-#    error:The connection.execute\(\) method:sqlalchemy.exc.RemovedIn20Warning
+    error:The autoload parameter is deprecated:sqlalchemy.exc.RemovedIn20Warning
     error:The current statement is being autocommitted using implicit autocommit:sqlalchemy.exc.RemovedIn20Warning
     error:The connection.execute\(\) method:sqlalchemy.exc.RemovedIn20Warning
 #    error:The current statement is being autocommitted using implicit autocommit:sqlalchemy.exc.RemovedIn20Warning
diff --git a/superset/extensions/metadb.py b/superset/extensions/metadb.py
index 9fb807a88c1..a1a26b488fd 100644
--- a/superset/extensions/metadb.py
+++ b/superset/extensions/metadb.py
@@ -331,7 +331,6 @@ class SupersetShillelaghAdapter(Adapter):
                     self.table,
                     metadata,
                     schema=self.schema,
-                    autoload=True,
                     autoload_with=engine,
                 )
             except NoSuchTableError as ex:
diff --git a/superset/migrations/versions/2020-01-08_01-17_e96dbf2cfef0_datasource_cluster_fk.py b/superset/migrations/versions/2020-01-08_01-17_e96dbf2cfef0_datasource_cluster_fk.py
index dbcbb3211c6..770f4ea7bde 100644
--- a/superset/migrations/versions/2020-01-08_01-17_e96dbf2cfef0_datasource_cluster_fk.py
+++ b/superset/migrations/versions/2020-01-08_01-17_e96dbf2cfef0_datasource_cluster_fk.py
@@ -45,8 +45,8 @@ def upgrade():
 
     # Update cluster_id values
     metadata = sa.MetaData(bind=bind)
-    datasources = sa.Table("datasources", metadata, autoload=True)
-    clusters = sa.Table("clusters", metadata, autoload=True)
+    datasources = sa.Table("datasources", metadata, autoload_with=bind)
+    clusters = sa.Table("clusters", metadata, autoload_with=bind)
 
     statement = datasources.update().values(
         cluster_id=sa.select(clusters.c.id)
@@ -87,8 +87,8 @@ def downgrade():
 
     # Update cluster_name values
     metadata = sa.MetaData(bind=bind)
-    datasources = sa.Table("datasources", metadata, autoload=True)
-    clusters = sa.Table("clusters", metadata, autoload=True)
+    datasources = sa.Table("datasources", metadata, autoload_with=bind)
+    clusters = sa.Table("clusters", metadata, autoload_with=bind)
 
     statement = datasources.update().values(
         cluster_name=sa.select(clusters.c.cluster_name)
diff --git a/superset/migrations/versions/2020-04-24_10-46_e557699a813e_add_tables_relation_to_row_level_.py b/superset/migrations/versions/2020-04-24_10-46_e557699a813e_add_tables_relation_to_row_level_.py
index 6dae3192970..42156e177ef 100644
--- a/superset/migrations/versions/2020-04-24_10-46_e557699a813e_add_tables_relation_to_row_level_.py
+++ b/superset/migrations/versions/2020-04-24_10-46_e557699a813e_add_tables_relation_to_row_level_.py
@@ -48,7 +48,7 @@ def upgrade():
         sa.PrimaryKeyConstraint("id"),
     )
 
-    rlsf = sa.Table("row_level_security_filters", metadata, autoload=True)
+    rlsf = sa.Table("row_level_security_filters", metadata, autoload_with=bind)
     filter_ids = sa.select(rlsf.c.id, rlsf.c.table_id)
 
     for row in bind.execute(filter_ids):
@@ -81,9 +81,9 @@ def downgrade():
         ),
     )
 
-    rlsf = sa.Table("row_level_security_filters", metadata, autoload=True)
-    rls_filter_tables = sa.Table("rls_filter_tables", metadata, autoload=True)
-    rls_filter_roles = sa.Table("rls_filter_roles", metadata, autoload=True)
+    rlsf = sa.Table("row_level_security_filters", metadata, autoload_with=bind)
+    rls_filter_tables = sa.Table("rls_filter_tables", metadata, autoload_with=bind)
+    rls_filter_roles = sa.Table("rls_filter_roles", metadata, autoload_with=bind)
 
     filter_tables = sa.select(rls_filter_tables.c.rls_filter_id).group_by(
         rls_filter_tables.c.rls_filter_id
diff --git a/superset/migrations/versions/2020-09-15_18-22_e5ef6828ac4e_add_rls_filter_type_and_grouping_key.py b/superset/migrations/versions/2020-09-15_18-22_e5ef6828ac4e_add_rls_filter_type_and_grouping_key.py
index d28633c09b9..02c3be3ce0c 100644
--- a/superset/migrations/versions/2020-09-15_18-22_e5ef6828ac4e_add_rls_filter_type_and_grouping_key.py
+++ b/superset/migrations/versions/2020-09-15_18-22_e5ef6828ac4e_add_rls_filter_type_and_grouping_key.py
@@ -44,7 +44,7 @@ def upgrade():
 
     bind = op.get_bind()
     metadata = sa.MetaData(bind=bind)
-    filters = sa.Table("row_level_security_filters", metadata, autoload=True)
+    filters = sa.Table("row_level_security_filters", metadata, autoload_with=bind)
     statement = filters.update().values(
         filter_type=utils.RowLevelSecurityFilterType.REGULAR.value
     )
diff --git a/superset/models/core.py b/superset/models/core.py
index d6cac8323d5..3c92a7f5eac 100755
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -1210,7 +1210,6 @@ class Database(CoreDatabase, AuditMixinNullable, ImportExportMixin):  # pylint:
                 table.table,
                 meta,
                 schema=table.schema or None,
-                autoload=True,
                 autoload_with=engine,
             )
 
diff --git a/superset/utils/core.py b/superset/utils/core.py
index eb83a110a65..689ef302800 100644
--- a/superset/utils/core.py
+++ b/superset/utils/core.py
@@ -641,9 +641,7 @@ def generic_find_constraint_name(
     table: str, columns: set[str], referenced: str, database: SQLAlchemy
 ) -> str | None:
     """Utility to find a constraint name in alembic migrations"""
-    tbl = sa.Table(
-        table, database.metadata, autoload=True, autoload_with=database.engine
-    )
+    tbl = sa.Table(table, database.metadata, autoload_with=database.engine)
 
     for fk in tbl.foreign_key_constraints:
         if fk.referred_table.name == referenced and set(fk.column_keys) == columns: