presto-main/src/main/java/io/prestosql/sql/planner/plan/AggregationNode.java/Aggregation/verifyArguments
class Aggregation:        private void verifyArguments(Step step)
        {
            int expectedArgumentCount;
            if (step == SINGLE || step == Step.PARTIAL) {
                expectedArgumentCount = resolvedFunction.getSignature().getArgumentTypes().size();
            }
            else {
                // Intermediate and final steps get the intermediate value and the lambda functions
                expectedArgumentCount = 1 + (int) resolvedFunction.getSignature().getArgumentTypes().stream()
                        .map(TypeSignature::getBase)
                        .filter(FunctionType.NAME::equals)
                        .count();
            }

            checkArgument(
                    expectedArgumentCount == arguments.size(),
                    "%s aggregation function %s has %s arguments, but %s arguments were provided to function call",
                    step,
                    resolvedFunction.getSignature(),
                    expectedArgumentCount,
                    arguments.size());
        }