public static TableDesc getTableDesc(Table tbl) {
    Properties props = tbl.getMetadata();
    props.put(serdeConstants.SERIALIZATION_LIB, tbl.getDeserializer().getClass().getName());
    if (tbl.getMetaTable() != null) {
      props.put("metaTable", tbl.getMetaTable());
    }
    if (tbl.getSnapshotRef() != null) {
      props.put(SNAPSHOT_REF, tbl.getSnapshotRef());
    }
    return (new TableDesc(tbl.getInputFormatClass(), tbl
        .getOutputFormatClass(), props));
  }
Gets the task id if we are running as a Hadoop job. Gets a random number otherwise.
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java