You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/05/03 16:32:14 UTC

[GitHub] [superset] betodealmeida commented on a diff in pull request #19930: fix: memoize primitives

betodealmeida commented on code in PR #19930:
URL: https://github.com/apache/superset/pull/19930#discussion_r863962113


##########
superset/db_engine_specs/base.py:
##########
@@ -864,18 +864,24 @@ def get_all_datasource_names(
         all_datasources: List[utils.DatasourceName] = []
         for schema in schemas:
             if datasource_type == "table":
-                all_datasources += database.get_all_table_names_in_schema(
-                    schema=schema,
-                    force=True,
-                    cache=database.table_cache_enabled,
-                    cache_timeout=database.table_cache_timeout,
+                all_datasources.extend(
+                    utils.DatasourceName(*datasource_name)
+                    for datasource_name in database.get_all_table_names_in_schema(
+                        schema=schema,
+                        force=True,
+                        cache=database.table_cache_enabled,
+                        cache_timeout=database.table_cache_timeout,

Review Comment:
   Great question, the cool thing about this solution is that it works with old cached values:
   
   ```python
   >>> from typing import NamedTuple
   >>>
   >>> class DatasourceName(NamedTuple):
   ...     table: str
   ...     schema: str
   ...
   >>> a = DatasourceName(table='t', schema='s')
   >>> DatasourceName(*a)
   DaasourceName(table='t', schema='s')
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org