korbit-ai[bot] commented on code in PR #31910:
URL: https://github.com/apache/superset/pull/31910#discussion_r1920727490


##########
superset/models/core.py:
##########
@@ -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,
     )

Review Comment:
   ### Cache key not handling None catalog properly <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### 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:
   ```python
   @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,
   )
   ```
   
   
   </details>
   
   ###### Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help 
Korbit improve your reviews.
   
   
   <!--- korbi internal id:f39efe63-d0df-449a-9c37-5d745d829cf9 -->
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to