diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java index 900642e73c..e25dc54e7d 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java @@ -1497,7 +1497,12 @@ public static void mvFileToFinalPath(Path specPath, Configuration hconf, // for CTAS or Create MV statements perfLogger.PerfLogBegin("FileSinkOperator", "moveSpecifiedFileStatus"); LOG.debug("CTAS/Create MV: Files being renamed: " + filesKept.toString()); - Utilities.moveSpecifiedFileStatus(fs, tmpPath, specPath, filesKept); + if (emptyBuckets.isEmpty()) { + fs.rename(tmpPath, specPath); + } else { + LOG.info("Duplicate files present. Moving files sequentially"); + Utilities.moveSpecifiedFileStatus(fs, tmpPath, specPath, filesKept); + } perfLogger.PerfLogEnd("FileSinkOperator", "moveSpecifiedFileStatus"); } else { // for rest of the statement e.g. INSERT, LOAD etc