Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CRUD action to refresh table metadata #3721

Merged
merged 1 commit into from
Oct 26, 2017
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
8 changes: 8 additions & 0 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,11 @@ How can I set a default filter on my dashboard?

Easy. Simply apply the filter and save the dashboard while the filter
is active.

How do I get Superset to refresh the schema of my table?
--------------------------------------------------------

When adding columns to a table, you can have Superset detect and merge the
new columns in by using the "Refresh Metadata" action in the
``Source -> Tables`` page. Simply check the box next to the tables
you want the schema refreshed, and click ``Actions -> Refresh Metadata``.
15 changes: 15 additions & 0 deletions superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from flask import Markup, flash, redirect
from flask_appbuilder import CompactCRUDMixin, expose
from flask_appbuilder.actions import action
from flask_appbuilder.models.sqla.interface import SQLAInterface

from flask_babel import lazy_gettext as _
Expand Down Expand Up @@ -272,6 +273,20 @@ def edit(self, pk):
return resp
return redirect('/superset/explore/table/{}/'.format(pk))

@action(
"refresh",
__("Refresh Metadata"),
__("Refresh column metadata"),
"fa-refresh")
def refresh(self, tables):
for t in tables:
t.fetch_metadata()
msg = _(
"Metadata refreshed for the following table(s): %(tables)s",
tables=", ".join([t.table_name for t in tables]))
flash(msg, 'info')
return redirect('/tablemodelview/list/')

appbuilder.add_view(
TableModelView,
"Tables",
Expand Down