Index: ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (revision 1170044) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java (working copy) @@ -77,7 +77,15 @@ fs.delete(targetPath, true); // if source exists, rename. Otherwise, create a empty directory if (fs.exists(sourcePath)) { + // If it multiple level of folder are there fs.rename is failing so first + // create the targetpath + fs.mkdirs(targetPath); if (!fs.rename(sourcePath, targetPath)) { + try { + fs.delete(targetPath, true); + } catch (IOException e) { + LOG.info("Unable to delete the path " + targetPath); + } throw new HiveException("Unable to rename: " + sourcePath + " to: " + targetPath); }