public static void clearDestForSubDirSrc(final HiveConf conf, Path dest,
      Path src, boolean isSrcLocal) throws IOException {
    FileSystem destFS = dest.getFileSystem(conf);
    FileSystem srcFS = src.getFileSystem(conf);
    if (isSubDir(src, dest, srcFS, destFS, isSrcLocal)) {
      final Path fullSrcPath = getQualifiedPathWithoutSchemeAndAuthority(src, srcFS);
      final Path fullDestPath = getQualifiedPathWithoutSchemeAndAuthority(dest, destFS);
      if (fullSrcPath.equals(fullDestPath)) {
        return;
      }
      Path parent = fullSrcPath;
      while (!parent.getParent().equals(fullDestPath)) {
        parent = parent.getParent();
      }
      FileStatus[] existingFiles = destFS.listStatus(
          dest, FileUtils.HIDDEN_FILES_PATH_FILTER);
      for (FileStatus fileStatus : existingFiles) {
        if (!fileStatus.getPath().getName().equals(parent.getName())) {
          destFS.delete(fileStatus.getPath(), true);
        }
      }
    }
  }
<p>
  Moves a file from one {@link Path} to another. If {@code isRenameAllowed} is true then the
  {@link FileSystem#rename(Path, Path)} method is used to move the file. If its false then the data is copied, if
  {@code isSrcLocal} is true then the {@link FileSystem#copyFromLocalFile(Path, Path)} method is used, else
  {@link FileUtils#copy(FileSystem, Path, FileSystem, Path, boolean, boolean, HiveConf)} is used.
</p>

<p>
  If the destination file already exists, then {@code _copy_[counter]} is appended to the file name, where counter
  is an integer starting from 1.
</p>

@param conf the {@link HiveConf} to use if copying data
@param sourceFs the {@link FileSystem} where the source file exists
@param sourcePath the {@link Path} to move
@param destFs the {@link FileSystem} to move the file to
@param destDirPath the {@link Path} to move the file to
@param isSrcLocal if the source file is on the local filesystem
@param isOverwrite if true, then overwrite destination file if exist else make a duplicate copy
@param isRenameAllowed true if the data should be renamed and not copied, false otherwise

@return the {@link Path} the source file was moved to

@throws IOException if there was an issue moving the file
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java