@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (writeId == -1) {
      throw new HiveException("Could not obtain Write ID for the surrogate_key function");
    }

    if (rowId > maxRowId) {
      throw new HiveException(String.format("Row ID is out of range (%d bits) in surrogate_key", rowIdBits));
    }

    long uniqueId = (writeId << (taskIdBits + rowIdBits)) + (taskId << rowIdBits) + rowId;
    rowId++;

    return new LongWritable(uniqueId);
  }
This function is not a deterministic function, and not a runtime constant.
The return value is sequence within a query with a unique staring point based on write_id and task_id
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFSurrogateKey.java