public Path createTezDir(Path scratchDir, Configuration conf)
      throws IOException {
    UserGroupInformation ugi;
    String userName = System.getProperty("user.name");
    try {
      ugi = Utils.getUGI();
      userName = ugi.getShortUserName();
    } catch (LoginException e) {
      throw new IOException(e);
    }

    scratchDir = new Path(scratchDir, userName);

    Path tezDir = getTezDir(scratchDir);
    if (!HiveConf.getBoolVar(conf, ConfVars.HIVE_RPC_QUERY_PLAN)) {
      FileSystem fs = tezDir.getFileSystem(conf);
      LOG.debug("TezDir path set " + tezDir + " for user: " + userName);
      // since we are adding the user name to the scratch dir, we do not
      // need to give more permissions here
      // Since we are doing RPC creating a dir is not necessary
      fs.mkdirs(tezDir);
    }

    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/DagUtils.java