Selaa lähdekoodia

HUE-3450 [metastore] Add column popularity to table page

Romain Rigaux 9 vuotta sitten
vanhempi
commit
3e8d331

+ 11 - 1
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -408,7 +408,7 @@
               table: self
             })
           }));
-          self.favouriteColumns(self.columns().slice(0, 3));
+          self.favouriteColumns(self.columns().slice(0, 5));
         },
         errorCallback: function () {
           self.loadingColumns(false);
@@ -469,6 +469,15 @@
                       })
                     );
                   }
+                  // Column popularity, stats
+                  $.each(self.optimizerDetails().sortedTotal(), function(index, optimizerCol) {
+                    var metastoreCol = $.grep(self.columns(), function(col) {
+                      return col.name() == optimizerCol.columnName();
+                    })
+                    if (metastoreCol.length > 0) {
+                      metastoreCol[0].popularity(optimizerCol.totalCount())
+                    }
+                  });
                 } else {
                   $(document).trigger("info", data.message);
                 }
@@ -551,6 +560,7 @@
     ko.mapping.fromJS(options.extendedColumn, {}, self);
 
     self.favourite = ko.observable(false);
+    self.popularity = ko.observable();
 
     self.comment.subscribe(function (newValue) {
       $.post('/metastore/table/' + self.table.database.name + '/' + self.table.name + '/alter_column', {

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

@@ -87,6 +87,7 @@ ${ assist.assistPanel() }
 <script type="text/html" id="metastore-columns-table">
   <div style="overflow-x: auto; overflow-y: hidden">
     <table class="table table-striped table-condensed table-nowrap">
+      <br/>
       <thead>
       <tr>
         <th width="2%">&nbsp;</th>
@@ -94,7 +95,10 @@ ${ assist.assistPanel() }
         <th width="2%" class="no-sort">&nbsp;</th>
   ##       <th width="1%">&nbsp;</th>
         <th width="17%">${_('Name')}</th>
-        <th width="29%">${_('Type')}</th>
+        <th width="15%">${_('Type')}</th>
+        <!-- ko if: $root.optimizerEnabled  -->
+          <th width="15%">${_('Popularity')}</th>
+        <!-- /ko -->
         <th width="50%">${_('Comment')}</th>
       </tr>
       </thead>
@@ -125,6 +129,13 @@ ${ assist.assistPanel() }
             <!-- /ko -->
           </td>
           <td data-bind="text: type"></td>
+          <!-- ko if: $root.optimizerEnabled  -->
+          <td>
+            <div class="progress" style="height: 10px; width: 70px; margin-top:5px;">
+              <div class="bar" style="background-color: #338bb8" data-bind="style: { 'width' : popularity() + '%' }, attr: { 'title': popularity() } "></div>
+            </div>
+          </td>
+          <!-- /ko -->
           <td>
             <span data-bind="editable: comment, editableOptions: {enabled: true, placement: 'left', emptytext: '${ _ko('Add a comment...') }' }" class="editable editable-click editable-empty">
               ${ _('Add a comment...') }</span>
@@ -687,6 +698,7 @@ ${ assist.assistPanel() }
 </script>
 
 <script type="text/html" id="metastore-queries-tab">
+  <br/>
   <i class="fa fa-spinner fa-spin" data-bind="visible: $root.loadingQueries"></i>
   <table data-bind="visible: ! loadingQueries() && $data.optimizerDetails().FullQueryList().length > 0" class="table table-condensed">
     <thead>

+ 8 - 2
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -100,8 +100,14 @@ def table_details(request):
 
   api = OptimizerApi()
 
-  response['details'] = api.table_details(table_name=table_name)['details']
-  response['status'] = 0
+  data = api.table_details(table_name=table_name)
+
+  if data['status'] == 'success':
+    response['status'] = 0
+  response['details'] = data['details']
+  
+#   if 'No table with that name' in response['details']:
+#     response['status'] = -1
 
   return JsonResponse(response)