Fix regression in distributing sum aggregation

fix_120_custom_aggregates_distribute_multiarg
Philip Dubé 2019-10-18 20:29:47 +00:00
parent 04b5dc39bc
commit 79fde86d6c
1 changed files with 15 additions and 0 deletions

View File

@ -1934,6 +1934,21 @@ MasterAggregateExpression(Aggref *originalAggregate,
newMasterAggregate->aggdistinct = NULL;
newMasterAggregate->aggfilter = NULL;
if (aggregateType != AGGREGATE_CUSTOM_COMMUTE)
{
/*
* Aggregates like sum may require passing to different signatures.
* eg sum(bigint) returns numeric, so we need to use sum(numeric) on coordinator.
*/
const char *aggregateName = AggregateNames[aggregateType];
Oid aggregateFunctionId = AggregateFunctionOid(aggregateName,
workerReturnType);
Oid masterReturnType = get_func_rettype(aggregateFunctionId);
newMasterAggregate->aggfnoid = aggregateFunctionId;
newMasterAggregate->aggtype = masterReturnType;
}
column = makeVar(masterTableId, walkerContext->columnId, workerReturnType,
workerReturnTypeMod, workerCollationId, columnLevelsUp);
walkerContext->columnId++;