Просмотр исходного кода

HUE-6132 [editor] Update table upload input format

Romain Rigaux 8 лет назад
Родитель
Сommit
2d7c3d5

+ 6 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -675,7 +675,9 @@ from notebook.conf import get_ordered_interpreters
         <!-- ko if: sourceType === 'hive' || sourceType === 'impala' -->
         <!-- ko if: typeof databaseName !== 'undefined' -->
           <!-- ko if: IS_HUE_4 -->
-            <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName ); }" title="${_('Create table')}" href="javascript:void(0)"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+            <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName ); }" title="${_('Create table')}" href="javascript:void(0)">
+              <i class="pointer fa fa-plus" title="${_('Create table')}"></i>
+            </a>
           <!-- /ko -->
           <!-- ko if: ! IS_HUE_4 -->
             <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + databaseName }"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
@@ -1659,7 +1661,9 @@ from notebook.conf import get_ordered_interpreters
     <br/>
     <ul data-bind="foreach: activeTables">
       <li data-bind="click: function (data, event) { showContextPopover(data, event, 'left') }">
-        <span data-bind="text: name"></span> <i class="fa fa-info"></i> <i class="fa fa-fw fa-clock-o muted" title="02/01/2017 10:15 PM"></i>
+        <span data-bind="text: name"></span>
+        <i class="fa fa-info"></i>
+        <i class="fa fa-fw fa-clock-o muted" title="02/01/2017 10:15 PM"></i>
       </li>
     </ul>
 

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

@@ -341,9 +341,19 @@ def upload_table_stats(request):
   table_ddls = []
 
   for db_table in db_tables:
-    path = _get_table_name(db_table)
+    path = _get_table_name(db_table['name'])
 
     try:
+      if with_ddl:
+        db = dbms.get(request.user)
+        query = hql_query('SHOW CREATE TABLE `%(database)s`.`%(table)s`' % path)
+        handle = db.execute_and_wait(query, timeout_sec=5.0)
+
+        if handle:
+          result = db.fetch(handle, rows=5000)
+          db.close(handle)
+          table_ddls.append((0, 0, '\n'.join([row[0] for row in result.rows()])))
+
       full_table_stats = json.loads(get_table_stats(request, database=path['database'], table=path['table']).content)
       stats = dict((stat['data_type'], stat['comment']) for stat in full_table_stats['stats'])
 
@@ -377,17 +387,6 @@ def upload_table_stats(request):
             "num_trues": col_stats['num_trues'] if col_stats.get('num_trues', '') != '' else -1,
             "num_falses": col_stats['num_falses'] if col_stats.get('num_falses', '') != '' else -1,
           })
-
-      if with_ddl:
-        db = dbms.get(request.user)
-        query = hql_query('SHOW CREATE TABLE `%(database)s`.`%(table)s`' % path)
-        handle = db.execute_and_wait(query, timeout_sec=5.0)
-
-        if handle:
-          result = db.fetch(handle, rows=5000)
-          db.close(handle)
-          table_ddls.append((0, 0, '\n'.join([row[0] for row in result.rows()])))
-
     except Exception, e:
       LOG.exception('Skipping upload of %s: %s' % (db_table, e))
 

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

@@ -1610,6 +1610,7 @@ var EditorViewModel = (function() {
 
     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),
@@ -1618,7 +1619,7 @@ var EditorViewModel = (function() {
         with_ddl: ko.mapping.toJSON(true)
       }, function(data) {
         if (data.status == 0) {
-          $(document).trigger("info", activeTables + " stats uploaded successfully.");
+          $(document).trigger("info", $.map(activeTables, function(table) { return table.name; }) + " stats sent to analyse.");
           if (data.upload_table_ddl) {
             self.watchUploadStatus(data.upload_table_ddl.status.workloadId);
           }