private boolean createAndSetPathOwner(Path destPath, Path sourcePath, HiveConf clonedConf) throws IOException {
    FileSystem targetFs = destPath.getFileSystem(clonedConf);
    boolean createdDir = false;
    if (!targetFs.exists(destPath)) {
      // target path is created even if the source path is missing, so that ddl task does not try to create it.
      if (!targetFs.mkdirs(destPath)) {
        throw new IOException(ErrorMsg.REPL_FILE_SYSTEM_OPERATION_RETRY.format(
          destPath + " is not a directory or unable to create one"));
      }
      createdDir = true;
    }

    FileStatus status;
    try {
      status = sourcePath.getFileSystem(clonedConf).getFileStatus(sourcePath);
    } catch (FileNotFoundException e) {
      // Don't delete target path created else ddl task will try to create it using user hive and may fail.
      LOG.warn("source path missing " + sourcePath);
      return createdDir;
    }
    LOG.info("Setting permission for path dest {} from source {} owner {} : {} : {}",
            destPath, sourcePath, status.getOwner(), status.getGroup(), status.getPermission());
    preserveDistCpAttributes(destPath, sourcePath, clonedConf, status);
    return createdDir;
  }
DirCopyTask, mainly to be used to copy External table data.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/DirCopyTask.java