private String getActualOutputWorkName(GenTezProcContext context, ReduceWork reduceWork) {
    return context.opMergeJoinWorkMap.values().stream()
        .filter(mergeJoinWork -> mergeJoinWork.getBaseWorkList().contains(reduceWork))
        .map(MergeJoinWork::getMainWork)
        // getMainWork() == null means that we have not visited the leaf Operator of MergeJoinWork.
        // In this case, GenTezWork will adjust the output name of merged works
        // by calling MergeJoinWork.addMergedWork() with non-null argument for parameter work.
        .filter(Objects::nonNull)
        .findAny().orElse(reduceWork).getName();
  }
If the given reduceWork is the merged work of a MergeJoinWork, return the name of that MergeJoinWork.
Otherwise, return the name of the given reduceWork.
ql/src/java/org/apache/hadoop/hive/ql/parse/GenTezWork.java