private void removeLocalTmpFiles(String sessionName, String localTmpdir) {
    File[] files = new File(localTmpdir).listFiles(fn -> fn.getName().startsWith(sessionName));
    if (files != null) {
      for (File file : files) {
        if (file.canWrite() && file.delete()) {
          consoleMessage("While removing '" + sessionName + "' dangling scratch dir from HDFS, "
                  + "local tmp session file '" + file.getPath() + "' has been cleaned as well.");
        } else {
          consoleMessage("Even though '" + sessionName + "' is marked as dangling session dir, "
                  + "local tmp session file '" + file.getPath() + "' could not be removed.");
        }
      }
    }
  }
While deleting dangling scratch dirs from hdfs, we can clean corresponding local files as well
@param sessionName prefix to determine removable tmp files
@param localTmpdir local tmp file location
ql/src/java/org/apache/hadoop/hive/ql/session/ClearDanglingScratchDir.java