Index: metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (date 1418370569000) +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (revision ) @@ -1508,8 +1508,16 @@ if (!success) { ms.rollbackTransaction(); } else if (deleteData && !isExternal) { - boolean ifPurge = envContext != null && - Boolean.parseBoolean(envContext.getProperties().get("ifPurge")); + // Data needs deletion. Check if trash may be skipped. + // Trash may be skipped iff: + // 1. deleteData == true, obviously. + // 2. tbl is external. + // 3. Either + // 3.1. User has specified PURGE from the commandline, and if not, + // 3.2. User has set the table to auto-purge. + boolean ifPurge = ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge"))) + || + (tbl.isSetParameters() && tbl.getParameters().get("auto.purge").equalsIgnoreCase("true")); // Delete the data in the partitions which have other locations deletePartitionData(partPaths, ifPurge); // Delete the data in the table @@ -2552,8 +2560,15 @@ } else if (deleteData && ((partPath != null) || (archiveParentDir != null))) { if (tbl != null && !isExternal(tbl)) { // Data needs deletion. Check if trash may be skipped. - boolean mustPurge = (envContext != null) - && Boolean.parseBoolean(envContext.getProperties().get("ifPurge")); + // Trash may be skipped iff: + // 1. deleteData == true, obviously. + // 2. tbl is external. + // 3. Either + // 3.1. User has specified PURGE from the commandline, and if not, + // 3.2. User has set the table to auto-purge. + boolean mustPurge = ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge"))) + || + (tbl.isSetParameters() && tbl.getParameters().get("auto.purge").equalsIgnoreCase("true")); if (mustPurge) { LOG.info("dropPartition() will purge " + partPath + " directly, skipping trash."); } @@ -2714,8 +2729,15 @@ ms.rollbackTransaction(); } else if (deleteData && !isExternal(tbl)) { // Data needs deletion. Check if trash may be skipped. - boolean mustPurge = (envContext != null) - && Boolean.parseBoolean(envContext.getProperties().get("ifPurge")); + // Trash may be skipped iff: + // 1. deleteData == true, obviously. + // 2. tbl is external. + // 3. Either + // 3.1. User has specified PURGE from the commandline, and if not, + // 3.2. User has set the table to auto-purge. + boolean mustPurge = ((envContext != null) && Boolean.parseBoolean(envContext.getProperties().get("ifPurge"))) + || + (tbl.isSetParameters() && tbl.getParameters().get("auto.purge").equalsIgnoreCase("true")); LOG.info( mustPurge? "dropPartition() will purge partition-directories directly, skipping trash." : "dropPartition() will move partition-directories to trash-directory.");