@Override
  public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
      throws SemanticException {
    MapJoinOperator mapJoinOp = (MapJoinOperator) nd;
    MapJoinDesc mapJoinDesc = mapJoinOp.getConf();

    if (mapJoinDesc.getFilterMap() == null) {
      return null;
    }

    int[][] filterMap = mapJoinDesc.getFilterMap();

    // 1. Extend ReduceSinkoperator if it's output is filtered by MapJoinOperator.
    for (byte pos = 0; pos < filterMap.length; pos++) {
      if (pos == mapJoinDesc.getPosBigTable() || filterMap[pos] == null) {
        continue;
      }

      ExprNodeDesc filterTagExpr =
          generateFilterTagExpression(filterMap[pos], mapJoinDesc.getFilters().get(pos));

      // Note that the parent RS for the given pos is retrieved in different way in MapJoinProcessor.
      // TODO: MapJoinProcessor.convertMapJoin() fixes the order of parent operators.
      //  Does other callers also fix the order as well as MapJoinProcessor.convertMapJoin()?
      ReduceSinkOperator parent = (ReduceSinkOperator) mapJoinOp.getParentOperators().get(pos);
      ReduceSinkDesc pRsConf = parent.getConf();

      // MapJoinProcessor.getMapJoinDesc() replaces filter expressions with backtracked one if
      // adjustParentsChildren is true.
      // As of now, ConvertJoinMapJoin.convertJoinDynamicPartitionedHashJoin() is the only functions that
      // calls this method with adjustParentsChildren = false. Therefore, we backtrack filter expressions
      // only if MapJoinDesc.isDynamicPartitionHashJoin is true, which is also the unique property of
      // ConvertJoinMapJoin.convertJoinDynamicPartitionedHashJoin().
      ExprNodeDesc mapSideFilterTagExpr;
      if (mapJoinDesc.isDynamicPartitionHashJoin()) {
        mapSideFilterTagExpr = ExprNodeDescUtils.backtrack(filterTagExpr, mapJoinOp, parent);
      } else {
        mapSideFilterTagExpr = filterTagExpr;
      }
      String filterColumnName = "_filterTag";

      pRsConf.getValueCols().add(mapSideFilterTagExpr);
      pRsConf.getOutputValueColumnNames().add(filterColumnName);
      pRsConf.getColumnExprMap()
          .put(Utilities.ReduceField.VALUE + "." + filterColumnName, mapSideFilterTagExpr);

      ColumnInfo filterTagColumnInfo =
          new ColumnInfo(Utilities.ReduceField.VALUE + "." + filterColumnName, shortType, "", false);
      parent.getSchema().getSignature().add(filterTagColumnInfo);

      TableDesc newTableDesc =
          PlanUtils.getReduceValueTableDesc(
              PlanUtils.getFieldSchemasFromColumnList(pRsConf.getValueCols(), "_col"));
      pRsConf.setValueSerializeInfo(newTableDesc);
    }

    // 2. Update MapJoinOperator's valueFilteredTableDescs.
    // Unlike HashTableSinkOperator used in MR engine, Tez engine directly passes rows from RS to MapJoin.
    // Therefore, RS's writer and MapJoin's reader should have the same TableDesc. We create valueTableDesc
    // here again because it can be different from RS's valueSerializeInfo due to ColumnPruner.
    List<TableDesc> newMapJoinValueFilteredTableDescs =
        new ArrayList<>(mapJoinOp.getParentOperators().size());
    for (byte pos = 0; pos < mapJoinOp.getParentOperators().size(); pos++) {
      TableDesc tableDesc;

      if (pos == mapJoinDesc.getPosBigTable() || filterMap[pos] == null) {
        // We did not change corresponding parent operator. Use the original tableDesc.
        tableDesc = mapJoinDesc.getValueFilteredTblDescs().get(pos);
      } else {
        // Create a new TableDesc based on corresponding parent RSOperator.
        ReduceSinkOperator parent = (ReduceSinkOperator) mapJoinOp.getParentOperators().get(pos);
        ReduceSinkDesc pRsConf = parent.getConf();

        tableDesc =
            PlanUtils.getMapJoinValueTableDesc(
                PlanUtils.getFieldSchemasFromColumnList(pRsConf.getValueCols(), "mapjoinvalue"));
      }

      newMapJoinValueFilteredTableDescs.add(tableDesc);
    }
    mapJoinDesc.setValueFilteredTblDescs(newMapJoinValueFilteredTableDescs);

    return null;
  }
Append a filterTag computation column to ReduceSinkOperators whose child is MapJoinOperator.
The added column expresses JoinUtil#isFiltered in the form of ExprNode.
The added column should be located at the end of row as CommonJoinOperator expects it.

This processor only affects small tables of MapJoin that run on Tez engine.
For big table, MapJoinOperator#process() calls CommonJoinOperator#getFilteredValue(), which adds filterTag.
For MapReduce engine, HashTableSinkOperator adds filterTag to every row.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/FiltertagAppenderProc.java