Przeglądaj źródła

HUE-8882 [tb] Improve invalidate logic when refreshing missing tables in the table browser

With this change it will first try to clear the cache and then invalidate as opposed to invalidating right away. When invalidate is required it will now invalidate the table instead of the database.
Johan Ahlen 6 lat temu
rodzic
commit
05b7608508

+ 13 - 4
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -230,10 +230,19 @@ var MetastoreViewModel = (function () {
           if (foundTables.length === 1) {
             self.source().namespace().database().setTable(foundTables[0], callback);
           } else if (clearDbCacheOnMissing) {
-            self.source().namespace().database().catalogEntry.clearCache({ invalidate: 'invalidate', silenceErrors: true }).then(function () {
-              self.source().namespace().database().load(function () {
-                setTableAfterLoad(false);
-              });
+            var dbEntry = self.source().namespace().database().catalogEntry;
+            dbEntry.getChildren({ refreshCache: true, silenceErrors: true }).then(function (childEntries) {
+              if (childEntries.some(function (childEntry) { return childEntry.name === tableDef.name })) {
+                self.source().namespace().database().load(function () {
+                  setTableAfterLoad(false);
+                });
+              } else {
+                dbEntry.clearCache({ invalidate: 'invalidate', silenceErrors: true, targetChild: tableDef.name }).then(function () {
+                  self.source().namespace().database().load(function () {
+                    setTableAfterLoad(false);
+                  });
+                });
+              }
             });
           }
         };

+ 3 - 2
desktop/core/src/desktop/js/catalog/dataCatalogEntry.js

@@ -300,6 +300,7 @@ class DataCatalogEntry {
    * @param {string} [options.invalidate] - 'cache', 'invalidate' or 'invalidateAndFlush', default 'cache', only used for Impala
    * @param {boolean} [options.cascade] - Default false, only used when the entry is for the source
    * @param {boolean} [options.silenceErrors] - Default false
+   * @param {string} [options.targetChild] - Optional specific child to invalidate
    * @return {CancellablePromise}
    */
   clearCache(options) {
@@ -323,7 +324,7 @@ class DataCatalogEntry {
           sourceType: self.getSourceType(),
           compute: self.compute,
           invalidate: invalidate,
-          path: self.path,
+          path: options.targetChild ? self.path.concat(options.targetChild) : self.path,
           silenceErrors: options.silenceErrors
         });
         self.dataCatalog.invalidatePromise = invalidatePromise;
@@ -408,7 +409,7 @@ class DataCatalogEntry {
       .getSourceMeta(options)
       .done(sourceMeta => {
         if (!sourceMeta || sourceMeta.notFound) {
-          deferred.reject();
+          deferred.reject('No source meta found');
           return;
         }
         const promises = [];