private Path createTezDir(String sessionId, String suffix) throws IOException {
    // tez needs its own scratch dir (per session)
    // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions via the pool.
    SessionState sessionState = SessionState.get();
    String hdfsScratchDir = sessionState == null ? HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCH_DIR) : sessionState
      .getHdfsScratchDirURIString();
    Path tezDir = new Path(hdfsScratchDir, TEZ_DIR);
    tezDir = new Path(tezDir, sessionId + ((suffix == null) ? "" : ("-" + suffix)));
    FileSystem fs = tezDir.getFileSystem(conf);
    FsPermission fsPermission = new FsPermission(HiveConf.getVar(conf, HiveConf.ConfVars.SCRATCH_DIR_PERMISSION));
    fs.mkdirs(tezDir, fsPermission);
    // Make sure the path is normalized (we expect validation to pass since we just created it).
    tezDir = DagUtils.validateTargetDir(tezDir, conf).getPath();

    // Directory removal will be handled by cleanup at the SessionState level.
    return tezDir;
  }
createTezDir creates a temporary directory in the scratchDir folder to
be used with Tez. Assumes scratchDir exists.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java