protected RexNode createAggregateNode(
          SqlAggFunction aggCall, RexNode leftRef, RexNode rightRef, RexBuilder rexBuilder) {
    switch (aggCall.getKind()) {
      case SUM:
      case SUM0:
      case COUNT:
        // SUM and COUNT are rolled up as SUM, hence SUM represents both here
        return rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
                ImmutableList.of(rightRef, leftRef));
      default:
        throw new AssertionError("Found an aggregation that could not be"
                + " recognized: " + aggCall);
    }
  }
This class implements the main algorithm of rewriting an MV maintenance plan to incremental.
Subclasses are represents Calcite rules which performs a rewriting to prepare the plan for incremental
view maintenance in case there exist aggregation operator, so we can
avoid the INSERT OVERWRITE and use a MERGE statement instead.

See subclasses for examples:
  {@link HiveAggregateInsertIncrementalRewritingRule},
  {@link HiveAggregateInsertDeleteIncrementalRewritingRule}

@param <T> Should be a class that wraps the right input of the top right outer join: the union branch
          which represents the plan which produces the delta records since the last view rebuild.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveAggregateIncrementalRewritingRuleBase.java