diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index ee6c564..a1935e7 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -2689,15 +2689,18 @@ private static void copyFiles(final HiveConf conf, final FileSystem destFs, Path destPath = new Path(destf, srcP.getName()); String srcGroup = srcFile.getGroup(); + boolean alreadyInheritedPerms = false; if (!needToCopy && !isSrcLocal) { for (int counter = 1; !destFs.rename(srcP,destPath); counter++) { destPath = new Path(destf, name + ("_copy_" + counter) + filetype); } } else { destPath = mvFile(conf, srcP, destPath, isSrcLocal, srcFs, destFs, name, filetype); + // The above mvFile() creates a new file in the desf and copy the bytes from srcP to destPath. + // The new file created will always inherit the permission of destf. + alreadyInheritedPerms = true; } - - if (inheritPerms) { + if (inheritPerms && !alreadyInheritedPerms) { HdfsUtils.setFullFileStatus(conf, fullDestStatus, srcGroup, destFs, destPath, false); } if (null != newFiles) {