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

dkuzmenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 10e5381cb6a HIVE-26149: Addendum: Fix materialized views removal when 
non-default MetaStoreFilterHook is configured (Denys Kuzmenko, reviewed by 
Karen Coppage)
10e5381cb6a is described below

commit 10e5381cb6a4215c0b25fe0cda0a26a084ba6a89
Author: Denys Kuzmenko <[email protected]>
AuthorDate: Wed Jun 22 12:22:04 2022 +0200

    HIVE-26149: Addendum: Fix materialized views removal when non-default 
MetaStoreFilterHook is configured (Denys Kuzmenko, reviewed by Karen Coppage)
    
    Closes #3395
---
 .../org/apache/hadoop/hive/ql/io/AcidUtils.java    |  6 ++---
 .../org/apache/hadoop/hive/ql/TestTxnCommands.java | 28 +++++++++++++++++++-
 .../thrift/gen-cpp/hive_metastore_constants.cpp    |  4 +++
 .../gen/thrift/gen-cpp/hive_metastore_constants.h  |  2 ++
 .../metastore/api/hive_metastoreConstants.java     |  4 +++
 .../src/gen/thrift/gen-php/metastore/Constant.php  | 12 +++++++++
 .../gen/thrift/gen-py/hive_metastore/constants.py  |  2 ++
 .../gen/thrift/gen-rb/hive_metastore_constants.rb  |  4 +++
 .../hadoop/hive/metastore/HiveMetaStoreClient.java | 16 ++++++------
 .../src/main/thrift/hive_metastore.thrift          |  6 ++++-
 .../hadoop/hive/metastore/AcidEventListener.java   |  3 ++-
 .../apache/hadoop/hive/metastore/HMSHandler.java   | 30 +++++++++++++---------
 .../apache/hadoop/hive/metastore/txn/TxnUtils.java |  6 +++++
 13 files changed, 97 insertions(+), 26 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java 
b/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
index 5ade4dabb80..9d79db66e21 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
@@ -421,9 +421,9 @@ public class AcidUtils {
   }
 
   public static boolean isTableSoftDeleteEnabled(Table table, HiveConf conf) {
-    return (HiveConf.getBoolVar(conf, 
ConfVars.HIVE_ACID_CREATE_TABLE_USE_SUFFIX)
-        || HiveConf.getBoolVar(conf, 
ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED))
-      && AcidUtils.isTransactionalTable(table)
+    boolean isSoftDelete = HiveConf.getBoolVar(conf, 
ConfVars.HIVE_ACID_CREATE_TABLE_USE_SUFFIX)
+      || HiveConf.getBoolVar(conf, ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED);
+    return isSoftDelete && AcidUtils.isTransactionalTable(table)
       && Boolean.parseBoolean(table.getProperty(SOFT_DELETE_TABLE));
   }
 
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java 
b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
index 7eb148a204d..f5928f932d3 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
@@ -35,6 +35,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.LocatedFileStatus;
@@ -42,9 +43,11 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.hive.conf.Constants;
 import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.IMetaStoreClient;
 import org.apache.hadoop.hive.metastore.MetastoreTaskThread;
+import org.apache.hadoop.hive.metastore.MetaStoreFilterHook;
 import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
 import org.apache.hadoop.hive.metastore.api.CompactionType;
 import org.apache.hadoop.hive.metastore.api.GetOpenTxnsInfoResponse;
@@ -116,11 +119,28 @@ public class TestTxnCommands extends 
TxnCommandsBaseForTests {
     HiveConf.setBoolVar(hiveConf, 
HiveConf.ConfVars.HIVE_ACID_RENAME_PARTITION_MAKE_COPY, false);
     HiveConf.setBoolVar(hiveConf, 
HiveConf.ConfVars.HIVE_ACID_CREATE_TABLE_USE_SUFFIX, false);
     HiveConf.setBoolVar(hiveConf, 
HiveConf.ConfVars.HIVE_ACID_TRUNCATE_USE_BASE, false);
+    
+    MetastoreConf.setClass(hiveConf, MetastoreConf.ConfVars.FILTER_HOOK,
+      DummyMetaStoreFilterHookImpl.class, MetaStoreFilterHook.class);
 
     HiveConf.setVar(hiveConf, 
HiveConf.ConfVars.HIVE_METASTORE_WAREHOUSE_EXTERNAL, 
       new Path(getWarehouseDir(), "ext").toUri().getPath());
   }
 
+  public static class DummyMetaStoreFilterHookImpl extends 
DefaultMetaStoreFilterHookImpl {
+    private static boolean blockResults = false;
+    
+    public DummyMetaStoreFilterHookImpl(Configuration conf) {
+      super(conf);
+    }
+    @Override
+    public List<String> filterTableNames(String catName, String dbName, 
List<String> tableList) {
+      if (blockResults) {
+        return new ArrayList<>();
+      }
+      return tableList;
+    }
+  }
 
   /**
    * tests that a failing Insert Overwrite (which creates a new base_x) is 
properly marked as
@@ -1713,12 +1733,18 @@ public class TestTxnCommands extends 
TxnCommandsBaseForTests {
     MetastoreConf.setLongVar(hiveConf, 
MetastoreConf.ConfVars.BATCH_RETRIEVE_MAX, 1);
     dropDatabaseCascadeNonBlocking();
   }
-  
+
   @Test
   public void testDropDatabaseCascadePerDbNonBlocking() throws Exception {
     dropDatabaseCascadeNonBlocking();
   }
   
+  @Test
+  public void testDropDatabaseCascadePerDbNonBlockingFilterTableNames() throws 
Exception {
+    DummyMetaStoreFilterHookImpl.blockResults = true;
+    dropDatabaseCascadeNonBlocking();
+  }
+  
   private void dropDatabaseCascadeNonBlocking() throws Exception {
     String database = "mydb";
     String tableName = "tab_acid";
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.cpp
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.cpp
index c252c4529c6..3524f62169b 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.cpp
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.cpp
@@ -85,6 +85,10 @@ hive_metastoreConstants::hive_metastoreConstants() {
 
   DEFAULT_TABLE_TYPE = "defaultTableType";
 
+  TXN_ID = "txnId";
+
+  WRITE_ID = "writeId";
+
 }
 
 }}} // namespace
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.h
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.h
index 9a96fa97488..533f00c7c81 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.h
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-cpp/hive_metastore_constants.h
@@ -52,6 +52,8 @@ class hive_metastoreConstants {
   std::string NO_CLEANUP;
   std::string CTAS_LEGACY_CONFIG;
   std::string DEFAULT_TABLE_TYPE;
+  std::string TXN_ID;
+  std::string WRITE_ID;
 };
 
 extern const hive_metastoreConstants g_hive_metastore_constants;
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/hive_metastoreConstants.java
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/hive_metastoreConstants.java
index 76540bebd87..da70e3b8390 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/hive_metastoreConstants.java
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/hive_metastoreConstants.java
@@ -83,4 +83,8 @@ package org.apache.hadoop.hive.metastore.api;
 
   public static final java.lang.String DEFAULT_TABLE_TYPE = "defaultTableType";
 
+  public static final java.lang.String TXN_ID = "txnId";
+
+  public static final java.lang.String WRITE_ID = "writeId";
+
 }
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Constant.php
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Constant.php
index 0912e817899..52b259798a1 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Constant.php
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-php/metastore/Constant.php
@@ -55,6 +55,8 @@ final class Constant extends \Thrift\Type\TConstant
     static protected $NO_CLEANUP;
     static protected $CTAS_LEGACY_CONFIG;
     static protected $DEFAULT_TABLE_TYPE;
+    static protected $TXN_ID;
+    static protected $WRITE_ID;
 
     protected static function init_DDL_TIME()
     {
@@ -240,4 +242,14 @@ final class Constant extends \Thrift\Type\TConstant
     {
         return "defaultTableType";
     }
+
+    protected static function init_TXN_ID()
+    {
+        return "txnId";
+    }
+
+    protected static function init_WRITE_ID()
+    {
+        return "writeId";
+    }
 }
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/constants.py
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/constants.py
index c691389c4eb..d15638b51db 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/constants.py
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-py/hive_metastore/constants.py
@@ -49,3 +49,5 @@ PARTITION_TRANSFORM_SPEC = "partition_transform_spec"
 NO_CLEANUP = "no_cleanup"
 CTAS_LEGACY_CONFIG = "create_table_as_external"
 DEFAULT_TABLE_TYPE = "defaultTableType"
+TXN_ID = "txnId"
+WRITE_ID = "writeId"
diff --git 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_constants.rb
 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_constants.rb
index cd8bd0001a7..1d68d03a9c9 100644
--- 
a/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_constants.rb
+++ 
b/standalone-metastore/metastore-common/src/gen/thrift/gen-rb/hive_metastore_constants.rb
@@ -81,3 +81,7 @@ CTAS_LEGACY_CONFIG = %q"create_table_as_external"
 
 DEFAULT_TABLE_TYPE = %q"defaultTableType"
 
+TXN_ID = %q"txnId"
+
+WRITE_ID = %q"writeId"
+
diff --git 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 2d68d6acafc..08d92f1ef25 100644
--- 
a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ 
b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -1614,11 +1614,11 @@ public class HiveMetaStoreClient implements 
IMetaStoreClient, AutoCloseable {
       List<String> materializedViews = getTables(req.getName(), ".*", 
TableType.MATERIALIZED_VIEW);
       for (String table : materializedViews) {
         // First we delete the materialized views
-        Table mview = getTable(getDefaultCatalog(conf), req.getName(), table);
+        Table materializedView = getTable(getDefaultCatalog(conf), 
req.getName(), table);
         boolean isSoftDelete = req.isSoftDelete() && Boolean.parseBoolean(
-          mview.getParameters().get(SOFT_DELETE_TABLE));
-        mview.setTxnId(req.getTxnId());
-        dropTable(mview, req.isDeleteData() && !isSoftDelete, true, false);
+          materializedView.getParameters().get(SOFT_DELETE_TABLE));
+        materializedView.setTxnId(req.getTxnId());
+        dropTable(materializedView, req.isDeleteData() && !isSoftDelete, true, 
false);
       }
 
       /**
@@ -1679,7 +1679,7 @@ public class HiveMetaStoreClient implements 
IMetaStoreClient, AutoCloseable {
         EnvironmentContext context = null;
         if (req.isSetTxnId()) {
           context = new EnvironmentContext();
-          context.putToProperties("txnId", String.valueOf(req.getTxnId()));
+          context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(req.getTxnId()));
           req.setDeleteManagedDir(false);
         }
         client.drop_table_with_environment_context(dbNameWithCatalog, 
table.getTableName(), 
@@ -1878,11 +1878,11 @@ public class HiveMetaStoreClient implements 
IMetaStoreClient, AutoCloseable {
     }
     if (options.writeId != null) {
       context = Optional.ofNullable(context).orElse(new EnvironmentContext());
-      context.putToProperties("writeId", options.writeId.toString());
+      context.putToProperties(hive_metastoreConstants.WRITE_ID, 
options.writeId.toString());
     }
     if (options.txnId != null) {
       context = Optional.ofNullable(context).orElse(new EnvironmentContext());
-      context.putToProperties("txnId", options.txnId.toString());
+      context.putToProperties(hive_metastoreConstants.TXN_ID, 
options.txnId.toString());
     }
     req.setEnvironmentContext(context);
     
@@ -1910,7 +1910,7 @@ public class HiveMetaStoreClient implements 
IMetaStoreClient, AutoCloseable {
     }
     if (tbl.isSetTxnId()) {
       context = Optional.ofNullable(context).orElse(new EnvironmentContext());
-      context.putToProperties("txnId", String.valueOf(tbl.getTxnId()));
+      context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(tbl.getTxnId()));
     }
     String catName = 
Optional.ofNullable(tbl.getCatName()).orElse(getDefaultCatalog(conf));
 
diff --git 
a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift 
b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
index dac4678886c..f7269500c1f 100644
--- 
a/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
+++ 
b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
@@ -3155,4 +3155,8 @@ const string TABLE_IS_CTLT = "created_with_ctlt",
 const string PARTITION_TRANSFORM_SPEC = "partition_transform_spec",
 const string NO_CLEANUP = "no_cleanup",
 const string CTAS_LEGACY_CONFIG = "create_table_as_external",
-const string DEFAULT_TABLE_TYPE = "defaultTableType",
\ No newline at end of file
+const string DEFAULT_TABLE_TYPE = "defaultTableType",
+  
+// ACID
+const string TXN_ID = "txnId",
+const string WRITE_ID = "writeId",
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AcidEventListener.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AcidEventListener.java
index eba80212bd3..48a264217b4 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AcidEventListener.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/AcidEventListener.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.HiveObjectType;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.Partition;
 import org.apache.hadoop.hive.metastore.api.Table;
@@ -239,7 +240,7 @@ public class AcidEventListener extends 
TransactionalMetaStoreEventListener {
   private long getTxnId(EnvironmentContext context) {
     return Optional.ofNullable(context)
       .map(EnvironmentContext::getProperties)
-      .map(prop -> prop.get("txnId"))
+      .map(prop -> prop.get(hive_metastoreConstants.TXN_ID))
       .map(Long::parseLong)
       .orElse(0L);
   }
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
index c5b8973a46e..564ae91637f 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java
@@ -1638,11 +1638,12 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
 
         if (materializedViews != null && !materializedViews.isEmpty()) {
           for (Table materializedView : materializedViews) {
-            if (materializedView.getSd().getLocation() != null) {
+            boolean isSoftDelete = 
TxnUtils.isTableSoftDeleteEnabled(materializedView, req.isSoftDelete());
+            
+            if (materializedView.getSd().getLocation() != null && 
!isSoftDelete) {
               Path materializedViewPath = wh.getDnsPath(new 
Path(materializedView.getSd().getLocation()));
-
-              if (!FileUtils.isSubdirectory(databasePath.toString(),
-                  materializedViewPath.toString())) {
+              
+              if (!FileUtils.isSubdirectory(databasePath.toString(), 
materializedViewPath.toString()) || req.isSoftDelete()) {
                 if (!wh.isWritable(materializedViewPath.getParent())) {
                   throw new MetaException("Database metadata not deleted since 
table: " +
                       materializedView.getTableName() + " has a parent 
location " + materializedViewPath.getParent() +
@@ -1651,8 +1652,15 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
                 tablePaths.add(materializedViewPath);
               }
             }
+            EnvironmentContext context = null;
+            if (isSoftDelete) {
+              context = new EnvironmentContext();
+              context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(req.getTxnId()));
+            }
             // Drop the materialized view but not its data
-            drop_table(req.getName(), materializedView.getTableName(), false);
+            drop_table_with_environment_context(
+                req.getName(), materializedView.getTableName(), false, 
context);
+            
             // Remove from all tables
             uniqueTableNames.remove(materializedView.getTableName());
           }
@@ -1677,12 +1685,10 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
 
         if (tables != null && !tables.isEmpty()) {
           for (Table table : tables) {
-
             // If the table is not external and it might not be in a 
subdirectory of the database
             // add it's locations to the list of paths to delete
+            boolean isSoftDelete = TxnUtils.isTableSoftDeleteEnabled(table, 
req.isSoftDelete());
             Path tablePath = null;
-            boolean isSoftDelete = req.isSoftDelete() && 
TxnUtils.isTransactionalTable(table) 
-              && 
Boolean.parseBoolean(table.getParameters().get(SOFT_DELETE_TABLE));
             
             boolean tableDataShouldBeDeleted = 
checkTableDataShouldBeDeleted(table, req.isDeleteData()) 
               && !isSoftDelete;
@@ -1707,7 +1713,7 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
             EnvironmentContext context = null;
             if (isSoftDelete) {
               context = new EnvironmentContext();
-              context.putToProperties("txnId", String.valueOf(req.getTxnId()));
+              context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(req.getTxnId()));
               req.setDeleteManagedDir(false);
             }
             // Drop the table but not its data
@@ -1725,7 +1731,7 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
           EnvironmentContext context = null;
           if (!req.isDeleteManagedDir()) {
             context = new EnvironmentContext();
-            context.putToProperties("txnId", String.valueOf(req.getTxnId()));
+            context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(req.getTxnId()));
           }
           dropEvent.setEnvironmentContext(context);
           transactionalListenerResponses =
@@ -5113,7 +5119,7 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
   static long getWriteId(EnvironmentContext context){
     return Optional.ofNullable(context)
       .map(EnvironmentContext::getProperties)
-      .map(prop -> prop.get("writeId"))
+      .map(prop -> prop.get(hive_metastoreConstants.WRITE_ID))
       .map(Long::parseLong)
       .orElse(0L);
   }
@@ -5848,7 +5854,7 @@ public class HMSHandler extends FacebookBase implements 
IHMSHandler {
   public RenamePartitionResponse rename_partition_req(RenamePartitionRequest 
req) throws TException {
     EnvironmentContext context = new EnvironmentContext();
     context.putToProperties(RENAME_PARTITION_MAKE_COPY, 
String.valueOf(req.isClonePart()));
-    context.putToProperties("txnId", String.valueOf(req.getTxnId()));
+    context.putToProperties(hive_metastoreConstants.TXN_ID, 
String.valueOf(req.getTxnId()));
     
     rename_partition(req.getCatName(), req.getDbName(), req.getTableName(), 
req.getPartVals(),
         req.getNewPart(), context, req.getValidWriteIdList());
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java
index 88a0eaeb761..e484a97d814 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnUtils.java
@@ -52,6 +52,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static org.apache.hadoop.hive.common.AcidConstants.SOFT_DELETE_TABLE;
 import static 
org.apache.hadoop.hive.metastore.DatabaseProduct.determineDatabaseProduct;
 
 public class TxnUtils {
@@ -177,6 +178,11 @@ public class TxnUtils {
                     
equals(parameters.get(hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES));
   }
 
+  public static boolean isTableSoftDeleteEnabled(Table table, boolean 
isSoftDelete) {
+    return isSoftDelete && TxnUtils.isTransactionalTable(table)
+      && Boolean.parseBoolean(table.getParameters().get(SOFT_DELETE_TABLE));
+  }
+  
   /**
    * Should produce the result as &lt;dbName&gt;.&lt;tableName&gt;.
    */

Reply via email to