private RelDataType getSumReturnType(RelDataTypeFactory typeFactory,
      RelDataType inputType) {
    switch (inputType.getSqlTypeName()) {
      case TINYINT:
      case SMALLINT:
      case INTEGER:
      case BIGINT:
        return TypeConverter.convert(TypeInfoFactory.longTypeInfo, typeFactory);
      case TIMESTAMP:
      case FLOAT:
      case DOUBLE:
      case VARCHAR:
      case CHAR:
        return TypeConverter.convert(TypeInfoFactory.doubleTypeInfo, typeFactory);
      case DECIMAL:
        return typeFactory.getTypeSystem().deriveSumType(typeFactory, inputType);
      default:
        // Unsupported types will be validated when GenericUDAFSum is initialized. We keep the original expression here
        return inputType;
    }
  }
Do a shallow clone of oldAggRel and update aggCalls. Could be refactored
into Aggregate and subclasses - but it's only needed for some
subclasses.

@param relBuilder Builder of relational expressions; at the top of its
                  stack is its input
@param oldAggregate LogicalAggregate to clone.
@param newCalls  New list of AggregateCalls
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateReduceFunctionsRule.java