private RelNode aggregateCorrelatorOutput(
          Correlate correlate,
          Project project,
          Set<Integer> isCount) {
    final RelNode left = correlate.getLeft();
    final JoinRelType joinType = correlate.getJoinType();

    // now create the new project
    final List<Pair<RexNode, String>> newProjects = Lists.newArrayList();

    // Project everything from the LHS and then those from the original
    // project
    final List<RelDataTypeField> leftInputFields =
            left.getRowType().getFieldList();

    for (int i = 0; i < leftInputFields.size(); i++) {
      newProjects.add(RexInputRef.of2(i, leftInputFields));
    }

    // Marked where the projected expr is coming from so that the types will
    // become nullable for the original projections which are now coming out
    // of the nullable side of the OJ.
    boolean projectPulledAboveLeftCorrelator =
            joinType.generatesNullsOnRight();

    for (Pair<RexNode, String> pair : project.getNamedProjects()) {
      RexNode newProjExpr =
              removeCorrelationExpr(
                      pair.left,
                      projectPulledAboveLeftCorrelator,
                      isCount);
      newProjects.add(Pair.of(newProjExpr, pair.right));
    }

    return RelOptUtil.createProject(correlate, Pair.left(newProjects), Pair.right(newProjects),
        false, relBuilder);
  }
Pulls a {@link Project} above a {@link Correlate} from its RHS input.
Enforces nullability for join output.

@param correlate  Correlate
@param project the original project as the RHS input of the join
@param isCount Positions which are calls to the <code>COUNT</code>
               aggregation function
@return the subtree with the new Project at the root
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelDecorrelator.java