diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index a8ef2f7..fe9bba1 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -728,6 +728,7 @@ HIVE_START_CLEANUP_SCRATCHDIR("hive.start.cleanup.scratchdir", false), HIVE_INSERT_INTO_MULTILEVEL_DIRS("hive.insert.into.multilevel.dirs", false), HIVE_WAREHOUSE_SUBDIR_INHERIT_PERMS("hive.warehouse.subdir.inherit.perms", false), + HIVE_WAREHOUSE_DATA_SKIPTRASH("hive.warehouse.data.skipTrash", false), // whether insert into external tables is allowed HIVE_INSERT_INTO_EXTERNAL_TABLES("hive.insert.into.external.tables", true), diff --git conf/hive-default.xml.template conf/hive-default.xml.template index e445cd4..3b3ca1a 100644 --- conf/hive-default.xml.template +++ conf/hive-default.xml.template @@ -1697,6 +1697,14 @@ + hive.warehouse.data.skipTrash + false + + Set this to true if you do not want table data to be moved to trash while dropping table. + + + + hive.exec.job.debug.capture.stacktraces true Whether or not stack traces parsed from the task logs of a sampled failed task for diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java index dafc419..cc9141a 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreFsImpl.java @@ -25,6 +25,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.shims.HadoopShims; import org.apache.hadoop.hive.shims.ShimLoader; @@ -40,8 +41,14 @@ public boolean deleteDir(FileSystem fs, Path f, boolean recursive, LOG.info("deleting " + f); HadoopShims hadoopShim = ShimLoader.getHadoopShims(); + boolean skipTrash = HiveConf.getBoolVar(conf, + HiveConf.ConfVars.HIVE_WAREHOUSE_DATA_SKIPTRASH); + try { - if (hadoopShim.moveToAppropriateTrash(fs, f, conf)) { + if (skipTrash) { + LOG.info("Not moving"+ f +" to trash due to configuration " + + HiveConf.ConfVars.HIVE_WAREHOUSE_DATA_SKIPTRASH + " is set to true."); + }else if (hadoopShim.moveToAppropriateTrash(fs, f, conf)) { LOG.info("Moved to trash: " + f); return true; }