@Override
  public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
      throws SemanticException {
    GenTezProcContext context = (GenTezProcContext) procCtx;
    UnionOperator union = (UnionOperator) nd;

    // simply need to remember that we've seen a union.
    context.currentUnionOperators.add(union);
    return null;
  }
FileSinkProcessor is a simple rule to remember seen unions for later
processing.
ql/src/java/org/apache/hadoop/hive/ql/parse/UnionProcessor.java