public static String generateExecutionId() {
    Random rand = new Random();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SSS");
    String executionId = "hive_" + format.format(new Date()) + "_"
        + Math.abs(rand.nextLong());
    return executionId;
  }
Generate a unique executionId.  An executionId, together with user name and
the configuration, will determine the temporary locations of all intermediate
files.

In the future, users can use the executionId to resume a query.
ql/src/java/org/apache/hadoop/hive/ql/Context.java