presto-main/src/main/java/io/prestosql/operator/aggregation/InternalAggregationFunction.java/InternalAggregationFunction/getIntermediateType
class InternalAggregationFunction:    public Type getIntermediateType()
    {
        if (intermediateType.size() == 1) {
            return getOnlyElement(intermediateType);
        }
        else {
            return RowType.anonymous(intermediateType);
        }
    }