You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by va...@apache.org on 2025/01/21 19:01:04 UTC

(superset) branch fix/load-cached-table-metadata created (now 4b9e906223)

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

vavila pushed a change to branch fix/load-cached-table-metadata
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 4b9e906223 fix: Load cached DB metadata as DatasourceName and add catalog to schema_list cache key

This branch includes the following new commits:

     new 4b9e906223 fix: Load cached DB metadata as DatasourceName and add catalog to schema_list cache key

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/01: fix: Load cached DB metadata as DatasourceName and add catalog to schema_list cache key

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vavila pushed a commit to branch fix/load-cached-table-metadata
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4b9e906223e86fe4e9469aeb845268b2c605536d
Author: Vitor Avila <vi...@preset.io>
AuthorDate: Tue Jan 21 16:00:48 2025 -0300

    fix: Load cached DB metadata as DatasourceName and add catalog to schema_list cache key
---
 superset/commands/database/tables.py |  7 +++++--
 superset/models/core.py              | 12 ++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/superset/commands/database/tables.py b/superset/commands/database/tables.py
index b28d4f065f..c8fa88400c 100644
--- a/superset/commands/database/tables.py
+++ b/superset/commands/database/tables.py
@@ -32,6 +32,7 @@ from superset.daos.database import DatabaseDAO
 from superset.exceptions import SupersetException
 from superset.extensions import db, security_manager
 from superset.models.core import Database
+from superset.utils.core import DatasourceName
 
 logger = logging.getLogger(__name__)
 
@@ -59,7 +60,8 @@ class TablesDatabaseCommand(BaseCommand):
                 catalog=self._catalog_name,
                 schema=self._schema_name,
                 datasource_names=sorted(
-                    self._model.get_all_table_names_in_schema(
+                    DatasourceName(*datasource_name)
+                    for datasource_name in self._model.get_all_table_names_in_schema(
                         catalog=self._catalog_name,
                         schema=self._schema_name,
                         force=self._force,
@@ -74,7 +76,8 @@ class TablesDatabaseCommand(BaseCommand):
                 catalog=self._catalog_name,
                 schema=self._schema_name,
                 datasource_names=sorted(
-                    self._model.get_all_view_names_in_schema(
+                    DatasourceName(*datasource_name)
+                    for datasource_name in self._model.get_all_view_names_in_schema(
                         catalog=self._catalog_name,
                         schema=self._schema_name,
                         force=self._force,
diff --git a/superset/models/core.py b/superset/models/core.py
index 39775291f1..6f32383ab8 100755
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -83,7 +83,7 @@ from superset.superset_typing import (
 )
 from superset.utils import cache as cache_util, core as utils, json
 from superset.utils.backports import StrEnum
-from superset.utils.core import DatasourceName, get_username
+from superset.utils.core import get_username
 from superset.utils.oauth2 import get_oauth2_access_token, OAuth2ClientConfigSchema
 
 config = app.config
@@ -798,7 +798,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin):  # pylint: disable
         self,
         catalog: str | None,
         schema: str,
-    ) -> set[DatasourceName]:
+    ) -> set[tuple[str, str, str | None]]:
         """Parameters need to be passed as keyword arguments.
 
         For unused parameters, they are referenced in
@@ -814,7 +814,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin):  # pylint: disable
         try:
             with self.get_inspector(catalog=catalog, schema=schema) as inspector:
                 return {
-                    DatasourceName(table, schema, catalog)
+                    (table, schema, catalog)
                     for table in self.db_engine_spec.get_table_names(
                         database=self,
                         inspector=inspector,
@@ -832,7 +832,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin):  # pylint: disable
         self,
         catalog: str | None,
         schema: str,
-    ) -> set[DatasourceName]:
+    ) -> set[tuple[str, str, str | None]]:
         """Parameters need to be passed as keyword arguments.
 
         For unused parameters, they are referenced in
@@ -848,7 +848,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin):  # pylint: disable
         try:
             with self.get_inspector(catalog=catalog, schema=schema) as inspector:
                 return {
-                    DatasourceName(view, schema, catalog)
+                    (view, schema, catalog)
                     for view in self.db_engine_spec.get_view_names(
                         database=self,
                         inspector=inspector,
@@ -873,7 +873,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin):  # pylint: disable
             yield sqla.inspect(engine)
 
     @cache_util.memoized_func(
-        key="db:{self.id}:schema_list",
+        key="db:{self.id}:catalog:{catalog}:schema_list",
         cache=cache_manager.cache,
     )
     def get_all_schema_names(