diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java index 082f1cbc09..d47c088fcf 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/FileSinkOperator.java @@ -794,7 +794,12 @@ protected void createBucketFiles(FSPaths fsp) throws HiveException { // in recent hadoop versions, use deleteOnExit to clean tmp files. if (isNativeTable() && fs != null && fsp != null && !conf.isMmTable() && !conf.isDirectInsert()) { - autoDelete = fs.deleteOnExit(fsp.outPaths[0]); + // Not sure why this is repeated here (its there since HIVE-6455), as it should get + // deleted in createBucketForFileIdx. Currently guarding it with < 0 condition to avoid + // duplicate exits/delete calls to NN. + if (totalFiles <= 0) { + autoDelete = fs.deleteOnExit(fsp.outPaths[0]); + } } } catch (Exception e) { throw new HiveException(e);