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 2018/10/26 00:48:34 UTC
[GitHub] betodealmeida commented on a change in pull request #6153: Move
metadata cache one layer up
betodealmeida commented on a change in pull request #6153: Move metadata cache one layer up
URL: https://github.com/apache/incubator-superset/pull/6153#discussion_r228376045
##########
File path: superset/models/core.py
##########
@@ -840,61 +863,130 @@ def inspector(self):
engine = self.get_sqla_engine()
return sqla.inspect(engine)
- def all_table_names(self, schema=None, force=False):
- if not schema:
- if not self.allow_multi_schema_metadata_fetch:
- return []
- tables_dict = self.db_engine_spec.fetch_result_sets(
- self, 'table', force=force)
- return tables_dict.get('', [])
-
- extra = self.get_extra()
- medatada_cache_timeout = extra.get('metadata_cache_timeout', {})
- table_cache_timeout = medatada_cache_timeout.get('table_cache_timeout')
- enable_cache = 'table_cache_timeout' in medatada_cache_timeout
- return sorted(self.db_engine_spec.get_table_names(
- inspector=self.inspector,
- db_id=self.id,
- schema=schema,
- enable_cache=enable_cache,
- cache_timeout=table_cache_timeout,
- force=force))
-
- def all_view_names(self, schema=None, force=False):
- if not schema:
- if not self.allow_multi_schema_metadata_fetch:
- return []
- views_dict = self.db_engine_spec.fetch_result_sets(
- self, 'view', force=force)
- return views_dict.get('', [])
+ @cache_util.memoized_func(
+ key=lambda *args, **kwargs: 'db:{db_id}:schema:None:table_list'.format(
+ db_id=kwargs.get('db_id')),
+ use_tables_cache=True)
+ def all_table_names_in_database(self, db_id=None, cache=False,
+ cache_timeout=None, force=False):
+ """
+ Parameters need to be passed as keyword arguments.
+ If cache=True, db_id must be passed in for setting cache key
+ """
+ if not self.allow_multi_schema_metadata_fetch:
+ return []
+ tables_dict = self.db_engine_spec.fetch_result_sets(self, 'table')
Review comment:
The result from the method `fetch_results_sets` is super confusing... took me a while to understand line 879.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org