Selaa lähdekoodia

[metastore] Revert to use GetSchemas() for the list of tables

Romain Rigaux 10 vuotta sitten
vanhempi
commit
e89caf5

+ 0 - 8
apps/metastore/src/metastore/conf.py

@@ -18,11 +18,3 @@
 from django.utils.translation import ugettext_lazy as _
 
 from desktop.lib.conf import Config
-
-
-HS2_GET_TABLES_MAX = Config(
-  key="hs2_get_tables_max",
-  help=_("The max number of records in the result set permitted to do a HS2 GetTables call."),
-  type=int,
-  default=250
-)

+ 1 - 1
apps/metastore/src/metastore/templates/describe_table.mako

@@ -313,7 +313,7 @@ ${ assist.assistPanel() }
                 </div>
 
                 <div class="tile">
-                  <h4>${ _('Columns') } (<span data-bind="text: favouriteColumns().length"></span>)</h4>
+                  <h4>${ _('Columns') } (<span data-bind="text: columns().length"></span>)</h4>
                   <!-- ko with: favouriteColumns -->
                   <!-- ko template: "metastore-columns-table" --><!-- /ko -->
                   <!-- /ko -->

+ 1 - 22
apps/metastore/src/metastore/templates/tables.mako

@@ -72,10 +72,8 @@ ${ components.menubar() }
                 <th width="1%"><div class="hueCheckbox selectAll fa" data-selectables="tableCheck"></div></th>
                 <th>&nbsp;</th>
                 <th>${_('Table Name')}</th>
-                % if has_metadata:
                 <th>${_('Comment')}</th>
                 <th>${_('Type')}</th>
-                % endif
               </tr>
             </thead>
             <tbody>
@@ -92,10 +90,8 @@ ${ components.menubar() }
                 <td>
                   <a class="tableLink" href="${ url('metastore:describe_table', database=database, table=table['name']) }" data-row-selector="true">${ table['name'] }</a>
                 </td>
-                % if has_metadata:
-                <td>${ smart_unicode(table['comment']) }</td>
+                <td>${ smart_unicode(table['comment']) if table['comment'] else '' }</td>
                 <td>${ smart_unicode(table['type']) }</td>
-                % endif
               </tr>
             % endfor
             </tbody>
@@ -169,10 +165,8 @@ ${ components.menubar() }
         {"bSortable": false, "sWidth": "1%" },
         {"bSortable": false, "sWidth": "1%" },
         null,
-        % if has_metadata:
         null,
         null
-        % endif
       ],
       "oLanguage": {
         "sEmptyTable": "${_('No data available')}",
@@ -231,21 +225,6 @@ ${ components.menubar() }
       toggleActions();
     });
 
-      $(".tableLink").mouseover(function() {
-      var _link = $(this);
-      $.ajax({
-        type: "GET",
-        url: "/metastore/table/${database}/" + $(this).text() + "/metadata",
-        dataType: "json",
-        data: {},
-        success: function (response) {
-          if (response && response.status == 0) {
-            _link.attr("title", response.data.comment).tooltip("show");
-          }
-        },
-      });
-    });
-
     $(".tableCheck").click(function () {
       if ($(this).attr("checked")) {
         $(this).removeClass("fa-check").removeAttr("checked");

+ 26 - 31
apps/metastore/src/metastore/views.py

@@ -36,7 +36,6 @@ from beeswax.models import SavedQuery, MetaInstall
 from beeswax.server import dbms
 from beeswax.server.dbms import get_query_server_config
 from filebrowser.views import location_to_url
-from metastore.conf import HS2_GET_TABLES_MAX
 from metastore.forms import LoadDataForm, DbForm
 from metastore.settings import DJANGO_APPS
 from notebook.connectors.base import Notebook
@@ -158,40 +157,36 @@ def show_tables(request, database=None):
 
     search_filter = request.GET.get('filter', '')
 
-    table_names = db.get_tables(database=database, table_names=search_filter)
-    tables = [{'name': table} for table in table_names]
-
-    has_metadata = False
-
-    if len(table_names) <= HS2_GET_TABLES_MAX.get():  # Only attempt to do a GetTables HS2 call for small result sets
-      try:
-        tables_meta = db.get_tables_meta(database=database, table_names=search_filter) # SparkSql returns []
-        if tables_meta:
-          tables = tables_meta
-          table_names = [table['name'] for table in tables_meta]
-          has_metadata = True
-      except Exception, ex:
-        LOG.exception('Unable to fetch table metadata')
+    tables = db.get_tables_meta(database=database, table_names=search_filter) # SparkSql returns []
+    table_names = [table['name'] for table in tables]
   except Exception, e:
     raise PopupException(_('Failed to retrieve tables for database: %s' % database), detail=e)
 
-  resp = render("tables.mako", request, {
-    'breadcrumbs': [
-      {
-        'name': database,
-        'url': reverse('metastore:show_tables', kwargs={'database': database})
-      }
-    ],
-    'tables': tables,
-    'db_form': db_form,
-    'search_filter': search_filter,
-    'database': database,
-    'has_metadata': has_metadata,
-    'table_names': json.dumps(table_names),
-    'has_write_access': has_write_access(request.user),
-  })
-  resp.set_cookie("hueBeeswaxLastDatabase", database, expires=90)
+  if request.REQUEST.get("format", "html") == "json":
+    resp = JsonResponse({
+        'status': 0,
+        'tables': tables,
+        'table_names': table_names,
+        'search_filter': search_filter
+    })
+  else:
+    resp = render("tables.mako", request, {
+      'breadcrumbs': [
+        {
+          'name': database,
+          'url': reverse('metastore:show_tables', kwargs={'database': database})
+        }
+      ],
+      'tables': tables,
+      'db_form': db_form,
+      'search_filter': search_filter,
+      'database': database,
+      'has_metadata': True,
+      'table_names': json.dumps(table_names),
+      'has_write_access': has_write_access(request.user),
+    })
 
+  resp.set_cookie("hueBeeswaxLastDatabase", database, expires=90)
   return resp
 
 

+ 1 - 0
desktop/libs/notebook/src/notebook/api.py

@@ -243,6 +243,7 @@ def historify(request):
   history_doc.save()
   history_doc1.save()
 
+  print history
   if history.get('id'): # If we come from a saved query
     Document2.objects.get(id=history['id']).dependencies.add(history_doc)