diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java index a1f8973..368d0c6 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/MoveTask.java @@ -127,10 +127,22 @@ private void moveFile(Path sourcePath, Path targetPath, boolean isDfsDir) LocalFileSystem dstFs = FileSystem.getLocal(conf); if (dstFs.delete(targetPath, true) || !dstFs.exists(targetPath)) { - console.printInfo(mesg, mesg_detail); // if source exists, rename. Otherwise, create a empty directory if (fs.exists(sourcePath)) { - fs.copyToLocalFile(sourcePath, targetPath); + try { + // create the destination if it does not exist + if (!dstFs.exists(targetPath)) { + FileUtils.mkdir(dstFs, targetPath, false, conf); + } + } catch (IOException e) { + throw new HiveException("Unable to create target directory for copy" + targetPath, e); + } + + FileSystem srcFs = sourcePath.getFileSystem(conf); + FileStatus[] srcs = srcFs.listStatus(sourcePath, FileUtils.HIDDEN_FILES_PATH_FILTER); + for (FileStatus status : srcs) { + fs.copyToLocalFile(status.getPath(), targetPath); + } } else { if (!dstFs.mkdirs(targetPath)) { throw new HiveException("Unable to make local directory: "