private boolean checkIfPathExist(Path sourcePath, UserGroupInformation proxyUser, HiveConf clonedConf) throws Exception {
    if (proxyUser == null) {
      return sourcePath.getFileSystem(clonedConf).exists(sourcePath);
    }
    return proxyUser.doAs((PrivilegedExceptionAction<Boolean>) () -> sourcePath.getFileSystem(clonedConf).exists(sourcePath));
  }
DirCopyTask, mainly to be used to copy External table data.
ql/src/java/org/apache/hadoop/hive/ql/exec/repl/DirCopyTask.java