@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (alreadyCheckedAndPassed) {
      return 0L;
    }

    LOG.debug("evaluate: vertex {}, task: {}, attempt: {} <-> vertex {}, task: {}, attempt: {}",
        currentVertexName, currentTaskNumber, currentTaskAttemptNumber, vertexName, taskNumberExpr,
        taskAttemptNumberExpr);

    if (vertexName.equals(currentVertexName)
        && GenericUDFExceptionInVertex.numberFitsExpression(currentTaskNumber, taskNumberExpr)
        && GenericUDFExceptionInVertex.numberFitsExpression(currentTaskAttemptNumber,
            taskAttemptNumberExpr)) {
      String message = String.format(
          "GenericUDFExceptionInVertex: found condition for throwing exception (vertex/task/attempt):"
              + "current %s / %d / %d matches criteria %s / %s / %s",
          currentVertexName, currentTaskNumber, currentTaskAttemptNumber, vertexName,
          taskNumberExpr, taskAttemptNumberExpr);
      LOG.info(message);
      throw new HiveException(message);
    } else {
      alreadyCheckedAndPassed = true;
      return 0L;
    }
  }
This class implements the UDF which can throw an exception in arbitrary vertex (typically mapper)
/ task / task attempt. For throwing exception in reducer side, where most probably
GroupByOperator codepath applies, GenericUDAFExceptionInVertex is used.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFExceptionInVertex.java