You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2017/10/26 23:17:59 UTC

[GitHub] mistercrunch closed pull request #3721: Add CRUD action to refresh table metadata

mistercrunch closed pull request #3721: Add CRUD action to refresh table metadata
URL: https://github.com/apache/incubator-superset/pull/3721
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/faq.rst b/docs/faq.rst
index cee767ae96..f5335f9d21 100644
--- a/docs/faq.rst
+++ b/docs/faq.rst
@@ -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``.
diff --git a/superset/connectors/sqla/views.py b/superset/connectors/sqla/views.py
index 630ce522ec..e8fdf8d3f6 100644
--- a/superset/connectors/sqla/views.py
+++ b/superset/connectors/sqla/views.py
@@ -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 _
@@ -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",


 

----------------------------------------------------------------
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