presto-main/src/main/java/io/prestosql/metadata/FunctionRegistry.java/FunctionRegistry/getAggregationFunctionMetadata
class FunctionRegistry:    public AggregationFunctionMetadata getAggregationFunctionMetadata(ResolvedFunction resolvedFunction)
    {
        SqlFunction function = getSpecializedFunctionKey(resolvedFunction).getFunction();
        checkArgument(function instanceof SqlAggregationFunction, "%s is not an aggregation function", resolvedFunction);

        SqlAggregationFunction aggregationFunction = (SqlAggregationFunction) function;
        if (!aggregationFunction.isDecomposable()) {
            return new AggregationFunctionMetadata(aggregationFunction.isOrderSensitive(), Optional.empty());
        }

        InternalAggregationFunction implementation = getAggregateFunctionImplementation(resolvedFunction);
        return new AggregationFunctionMetadata(aggregationFunction.isOrderSensitive(), Optional.of(implementation.getIntermediateType().getTypeSignature()));
    }