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 1f9fb3b897..3ef9941c70 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 @@ -89,6 +89,7 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.PathFilter; import org.apache.hadoop.fs.permission.FsAction; +import org.apache.hadoop.hdfs.DFSUtilClient; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hive.common.FileUtils; import org.apache.hadoop.hive.common.HiveStatsUtils; @@ -4062,7 +4063,7 @@ private static void copyFiles(final HiveConf conf, final FileSystem destFs, Arrays.sort(files); for (final FileStatus srcFile : files) { final Path srcP = srcFile.getPath(); - final boolean needToCopy = needToCopy(srcP, destf, srcFs, destFs, configuredOwner, isManaged); + final boolean needToCopy = needToCopy(conf, srcP, destf, srcFs, destFs, configuredOwner, isManaged); final boolean isRenameAllowed = !needToCopy && !isSrcLocal; @@ -4377,7 +4378,7 @@ public static boolean moveFile(final HiveConf conf, Path srcf, final Path destf, destFs.copyFromLocalFile(srcf, destf); return true; } else { - if (needToCopy(srcf, destf, srcFs, destFs, configuredOwner, isManaged)) { + if (needToCopy(conf, srcf, destf, srcFs, destFs, configuredOwner, isManaged)) { //copy if across file system or encryption zones. LOG.debug("Copying source " + srcf + " to " + destf + " because HDFS encryption zones are different."); return FileUtils.copy(srcf.getFileSystem(conf), srcf, destf.getFileSystem(conf), destf, @@ -4502,7 +4503,7 @@ static private HiveException getHiveException(Exception e, String msg, String lo * TODO- consider if need to do this for different file authority. * @throws HiveException */ - static private boolean needToCopy(Path srcf, Path destf, FileSystem srcFs, + static private boolean needToCopy(final HiveConf conf, Path srcf, Path destf, FileSystem srcFs, FileSystem destFs, String configuredOwner, boolean isManaged) throws HiveException { //Check if different FileSystems if (!FileUtils.equalsFileSystem(srcFs, destFs)) { @@ -4543,6 +4544,10 @@ static private boolean needToCopy(Path srcf, Path destf, FileSystem srcFs, } } + // if Encryption not enabled, no copy needed + if (!DFSUtilClient.isHDFSEncryptionEnabled(conf)) { + return false; + } //Check if different encryption zones HadoopShims.HdfsEncryptionShim srcHdfsEncryptionShim = SessionState.get().getHdfsEncryptionShim(srcFs); HadoopShims.HdfsEncryptionShim destHdfsEncryptionShim = SessionState.get().getHdfsEncryptionShim(destFs);