Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ def safe_sqlalchemy_uri(self) -> str:
return self.sqlalchemy_uri

@cache_util.memoized_func(
key="db:{self.id}:schema:{schema}:table_list",
key="db:{self.id}:catalog:{catalog}:schema:{schema}:table_list",
cache=cache_manager.cache,
)
Comment on lines 793 to 796
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache key not handling None catalog properly category Functionality

Tell me more
What is the issue?

The cache key for get_all_table_names_in_schema uses {catalog} even when catalog is None, which could cause cache conflicts for databases not supporting catalogs.

Why this matters

When catalog support is not enabled for a database (allow_multi_catalog=False), passing None as catalog could still create different cache keys, defeating the caching mechanism's purpose and potentially causing unnecessary database queries.

Suggested change ∙ Feature Preview

Modify the cache key to only include catalog when it's not None or when the database supports multi-catalog:

@cache_util.memoized_func(
    key=lambda self, catalog, schema: 
        f"db:{self.id}:" + 
        (f"catalog:{catalog}:" if catalog and self.allow_multi_catalog else "") + 
        f"schema:{schema}:table_list",
    cache=cache_manager.cache,
)
Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.

def get_all_table_names_in_schema(
Expand Down Expand Up @@ -825,7 +825,7 @@ def get_all_table_names_in_schema(
raise self.db_engine_spec.get_dbapi_mapped_exception(ex) from ex

@cache_util.memoized_func(
key="db:{self.id}:schema:{schema}:view_list",
key="db:{self.id}:catalog:{catalog}:schema:{schema}:view_list",
cache=cache_manager.cache,
)
def get_all_view_names_in_schema(
Expand Down
Loading