Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion superset/cache_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def wrap(f):
def wrapped_f(cls, *args, **kwargs):
cache_key = key(*args, **kwargs)
o = tables_cache.get(cache_key)
if o is not None:
if not kwargs['force'] and o is not None:
return o
o = f(cls, *args, **kwargs)
tables_cache.set(cache_key, o, timeout=timeout)
Expand Down
4 changes: 2 additions & 2 deletions superset/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def update_datasources_cache():
for database in db.session.query(models.Database).all():
print('Fetching {} datasources ...'.format(database.name))
try:
database.all_table_names()
database.all_view_names()
database.all_table_names(force=True)
database.all_view_names(force=True)
except Exception as e:
print('{}'.format(e.message))

Expand Down
4 changes: 2 additions & 2 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def convert_dttm(cls, target_type, dttm):
@cache_util.memoized_func(
timeout=600,
key=lambda *args, **kwargs: 'db:{}:{}'.format(args[0].id, args[1]))
def fetch_result_sets(cls, db, datasource_type):
def fetch_result_sets(cls, db, datasource_type, force=False):
"""Returns the dictionary {schema : [result_set_name]}.

Datasource_type can be 'table' or 'view'.
Expand Down Expand Up @@ -260,7 +260,7 @@ def show_partition_pql(
@cache_util.memoized_func(
timeout=600,
key=lambda *args, **kwargs: 'db:{}:{}'.format(args[0].id, args[1]))
def fetch_result_sets(cls, db, datasource_type):
def fetch_result_sets(cls, db, datasource_type, force=False):
"""Returns the dictionary {schema : [result_set_name]}.

Datasource_type can be 'table' or 'view'.
Expand Down
10 changes: 6 additions & 4 deletions superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,15 +852,17 @@ def inspector(self):
engine = self.get_sqla_engine()
return sqla.inspect(engine)

def all_table_names(self, schema=None):
def all_table_names(self, schema=None, force=False):
if not schema:
tables_dict = self.db_engine_spec.fetch_result_sets(self, 'table')
tables_dict = self.db_engine_spec.fetch_result_sets(
self, 'table', force=force)
return tables_dict.get("", [])
return sorted(self.inspector.get_table_names(schema))

def all_view_names(self, schema=None):
def all_view_names(self, schema=None, force=False):
if not schema:
views_dict = self.db_engine_spec.fetch_result_sets(self, 'view')
views_dict = self.db_engine_spec.fetch_result_sets(
self, 'view', force=force)
return views_dict.get("", [])
views = []
try:
Expand Down