Преглед на файлове

HUE-6712 [metastore] Properly refresh tables and databases when creating/dropping

Try to issue only one refresh in case of many actions.
Add support for refresh on DROP for Impala cache.
Add support for DATABASE for Impala cache.
Romain Rigaux преди 8 години
родител
ревизия
bcd1e2b
променени са 2 файла, в които са добавени 10 реда и са изтрити 17 реда
  1. 0 10
      desktop/core/src/desktop/templates/ko_components.mako
  2. 10 7
      desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

+ 0 - 10
desktop/core/src/desktop/templates/ko_components.mako

@@ -343,14 +343,6 @@ from desktop.views import _ko
               }
             });
 
-            var refreshAssist = function (snippet) {
-              var match = snippet.statement_raw().match(/CREATE TABLE `([^`]+)`/i);
-              if (match) {
-                var db = match[1];
-                huePubSub.publish('assist.invalidate.impala', { flush: false, database: db });
-              }
-              huePubSub.publish('assist.db.refresh', { sourceType: 'hive' });
-            };
             notebook.snippets()[0].status.subscribe(function(val){
               if (val == 'failed'){
                 //self.isIndexing(false);
@@ -361,13 +353,11 @@ from desktop.views import _ko
                 if (! snippet.result.handle().has_more_statements) {
                   // TODO: Show finish notification and clicking on it does onSuccessUrl
                   // or if still on initial spinner we redirect automatically to onSuccessUrl
-                  refreshAssist(snippet);
                   if (notebook.onSuccessUrl() && notebook.onSuccessUrl() !== 'assist.db.refresh') { // TODO: Similar if in in FB directory, also refresh FB dir
                     huePubSub.publish('open.link', notebook.onSuccessUrl());
                   }
                 } else { // Perform last DROP statement execute
                   snippet.execute();
-                  refreshAssist(snippet);
                 }
               }
             });

+ 10 - 7
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -708,13 +708,16 @@ var EditorViewModel = (function() {
 
     self.ddlNotification = ko.observable();
     self.delayedDDLNotification = ko.pureComputed(self.ddlNotification).extend({ rateLimit: { method: "notifyWhenChangesStop", timeout: 5000 } });
-    if (! vm.isNotificationManager()) {
-      window.setTimeout(function () {
-        self.delayedDDLNotification.subscribe(function (val) {
-          huePubSub.publish('assist.db.refresh', { sourceTypes: self.type() === 'impala' || self.type() === 'hive' ? ['hive', 'impala'] : [self.type()] });
-        });
-      }, 0);
-    }
+    window.setTimeout(function () {
+      self.delayedDDLNotification.subscribe(function (val) {
+        var match = self.statement().match(/(?:CREATE|DROP) (?:TABLE|DATABASE) `([^`]+)`/i); // For importer/metastore generated DDL only currently
+        if (match) {
+          var db = match[1];
+          huePubSub.publish('assist.invalidate.impala', { flush: false, database: db });
+        }
+        huePubSub.publish('assist.db.refresh', { sourceType: self.type() });
+      });
+    }, 0);
 
     self.progress.subscribe(function (val) {
       $(document).trigger("progress", {data: val, snippet: self});