Explorar o código

HUE-6132 [assistant] Extract table names from metastore table format

Romain Rigaux %!s(int64=8) %!d(string=hai) anos
pai
achega
60ea4b2

+ 3 - 3
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -341,7 +341,7 @@ def upload_table_stats(request):
   table_ddls = []
 
   for db_table in db_tables:
-    path = _get_table_name(db_table['name'])
+    path = _get_table_name(db_table)
 
     try:
       if with_ddl:
@@ -358,7 +358,7 @@ def upload_table_stats(request):
       stats = dict((stat['data_type'], stat['comment']) for stat in full_table_stats['stats'])
 
       table_stats.append({
-        'table_name': db_table,
+        'table_name': path['table'],
         'num_rows':  stats.get('numRows', -1),
         'last_modified_time':  stats.get('transient_lastDdlTime', -1),
         'total_size':  stats.get('totalSize', -1),
@@ -375,7 +375,7 @@ def upload_table_stats(request):
           col_stats = dict([(key, val) for col_stat in col_stats for key, val in col_stat.iteritems()])
 
           column_stats.append({
-            'table_name': db_table,
+            'table_name': path['table'],
             'column_name': col,
             'data_type': col_stats['data_type'],
             "num_distinct": int(col_stats.get('distinct_count')) if col_stats.get('distinct_count') != '' else -1,

+ 3 - 9
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1584,10 +1584,6 @@ var EditorViewModel = (function() {
       });
     };
 
-    huePubSub.subscribe("editor.workload.upload", function () {
-      self.loadQueryHistory(10);
-    });
-
     self.loadQueryHistory = function (n) {
       logGA('load_query_history');
 
@@ -1604,16 +1600,14 @@ var EditorViewModel = (function() {
       });
     };
 
-    huePubSub.subscribe("editor.table.stats.upload", function (activeTables) {
-      self.loadTableStats(activeTables);
-    });
-
     self.loadTableStats = function (activeTables) {
       logGA('load_table_stats');
       $(document).trigger("info", "Preparing table data...");
 
       $.post("/metadata/api/optimizer/upload/table_stats", {
-        db_tables: ko.mapping.toJSON(activeTables),
+        db_tables: ko.mapping.toJSON($.map(activeTables, function(table) {
+          return table.database.name + '.' + table.name;
+        })),
         sourcePlatform: ko.mapping.toJSON(self.type()),
         with_columns: ko.mapping.toJSON(true),
         with_ddl: ko.mapping.toJSON(true)

+ 8 - 0
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -3175,6 +3175,14 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       ko.applyBindings(viewModel, $('#${ bindableElement }')[0]);
       viewModel.init();
 
+      huePubSub.subscribe("editor.table.stats.upload", function (activeTables) {
+        viewModel.selectedNotebook().snippets()[0].loadTableStats(activeTables);
+      });
+
+      huePubSub.subscribe("editor.workload.upload", function () {
+        viewModel.selectedNotebook().snippets()[0].loadQueryHistory(10);
+      });
+
       if (location.getParameter("github_status") != "") {
         if (location.getParameter("github_status") == "0") {
           $.jHueNotify.info("${ _('User successfully authenticated to GitHub.') }");