This is an automated email from the ASF dual-hosted git repository.

lesun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new ac469a5  [GOBBLIN-1309] Abort when registration is happening against a 
view
ac469a5 is described below

commit ac469a5b399ae2f7a91ac726d940629b923870d4
Author: Lei Sun <[email protected]>
AuthorDate: Mon Nov 2 17:53:42 2020 -0800

    [GOBBLIN-1309] Abort when registration is happening against a view
    
    Closes #3146 from autumnust/abortview
---
 .../gobblin/hive/metastore/HiveMetaStoreBasedRegister.java     | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git 
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
 
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
index 31189ef..a2b6228 100644
--- 
a/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
+++ 
b/gobblin-hive-registration/src/main/java/org/apache/gobblin/hive/metastore/HiveMetaStoreBasedRegister.java
@@ -38,6 +38,7 @@ import 
org.apache.gobblin.source.extractor.extract.kafka.KafkaSource;
 import org.apache.gobblin.util.AvroUtils;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.metastore.IMetaStoreClient;
+import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
@@ -181,6 +182,15 @@ public class HiveMetaStoreBasedRegister extends 
HiveRegister {
         AutoReturnableObject<IMetaStoreClient> client = 
this.clientPool.getClient()) {
       Table table = HiveMetaStoreUtils.getTable(spec.getTable());
 
+      // Abort the rest of operations if a view is seen.
+      if (table.getTableType().equals(TableType.VIRTUAL_VIEW.name())) {
+        String msg = "Cannot register paths against a view on Hive for:" + 
spec.getPath()
+            + " on table:" + spec.getTable().toString();
+        log.info(msg);
+        HiveMetaStoreEventHelper.submitFailedPathRegistration(eventSubmitter, 
spec,
+            new UnsupportedOperationException(msg));
+      }
+
       createDbIfNotExists(client.get(), table.getDbName());
       createOrAlterTable(client.get(), table, spec);
 

Reply via email to