Jelajahi Sumber

HUE-5286 [metadata] Taking into account full prefixing of tables and columns

Romain Rigaux 9 tahun lalu
induk
melakukan
02f6180e46

+ 17 - 16
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -494,22 +494,23 @@ var MetastoreViewModel = (function () {
                   self.optimizerDetails(ko.mapping.fromJS(data.details));
 
                   // Bump the most important columns first
-//                  var topCol = self.optimizerDetails().topColumns().slice(0, 5);
-//                  if (topCol.length >= 3 && self.favouriteColumns().length > 0) {
-//                    self.favouriteColumns($.grep(self.columns(), function(col) {
-//                        return topCol.indexOf(col.name()) != -1;
-//                      })
-//                    );
-//                  }
+                  var topCols = $.map(self.optimizerDetails().topCols().slice(0, 5), function(item) { return item.name(); });
+                  if (topCols.length >= 3 && self.favouriteColumns().length > 0) {
+                    self.favouriteColumns($.grep(self.columns(), function(col) {
+                        return topCols.indexOf(col.name()) != -1;
+                      })
+                    );
+                  }
+
                   // Column popularity, stats
-//                  $.each(self.optimizerDetails().topColumns(), function(index, optimizerCol) {
-//                    var metastoreCol = $.grep(self.columns(), function(col) {
-//                      return col.name() == optimizerCol.columnName();
-//                    });
-//                    if (metastoreCol.length > 0) {
-//                      metastoreCol[0].popularity(optimizerCol.totalCount())
-//                    }
-//                  });
+                  $.each(self.optimizerDetails().topCols(), function(index, optimizerCol) {
+                    var metastoreCol = $.grep(self.columns(), function(col) {
+                      return col.name() == optimizerCol.name();
+                    });
+                    if (metastoreCol.length > 0) {
+                      metastoreCol[0].popularity(optimizerCol.score())
+                    }
+                  });
                 } else {
                   $(document).trigger("info", data.message);
                 }
@@ -546,7 +547,7 @@ var MetastoreViewModel = (function () {
       });
     };
 
-    self.deleteTags = function (tag) {console.log(tag);
+    self.deleteTags = function (tag) {
       $.post('/metadata/api/navigator/delete_tags', {
         id: ko.mapping.toJSON(self.navigatorStats().identity),
         tags: ko.mapping.toJSON([tag])

+ 11 - 1
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -81,7 +81,8 @@ def top_tables(request):
 
   tables = [{
       'eid': table['eid'],
-      'name': table['name'],
+      'database': _get_table_name(table['name'])['database'],
+      'name': _get_table_name(table['name'])['table'],
       'popularity': table['workloadPercent'],
       'column_count': table['columnCount'],
       'patternCount': table['patternCount'],
@@ -238,3 +239,12 @@ def upload_history(request):
   response['status'] = 0
 
   return JsonResponse(response)
+
+
+def _get_table_name(path):
+  if '.' in path:
+    database, table = path.split('.', 1)
+  else:
+    database, table = '', path
+
+  return {'database': database, 'table': table}

+ 2 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -422,7 +422,7 @@ var EditorViewModel = (function() {
     self.statementType = ko.observable(typeof snippet.statementType != "undefined" && snippet.statementType != null ? snippet.statementType : 'text');
     self.statementTypes = ko.observableArray(['text', 'file']); // Maybe computed later for Spark
     if (! vm.editorMode()) {
-      self.statementTypes.push('document');	
+      self.statementTypes.push('document');
     }
     self.statementPath = ko.observable(typeof snippet.statementPath != "undefined" && snippet.statementPath != null ? snippet.statementPath : '');
     self.statementPath.subscribe(function(newVal) {
@@ -2022,7 +2022,7 @@ var EditorViewModel = (function() {
     self.editorType.subscribe(function(newVal) {
       self.editorMode(newVal != 'notebook');
       if (self.editorMode()) {
-    	self.selectedNotebook().fetchHistory(); // Js error if notebook did not have snippets
+        self.selectedNotebook().fetchHistory(); // Js error if notebook did not have snippets
       }
     });
     self.editorTypeTitle = ko.observable(options.editor_type);