}
Aggregation aggFun;
RelDataType aggType;
if (origCall.getAggregation().getName().equals("COUNT")) {
aggFun = new SqlSumEmptyIsZeroAggFunction(origCall.getType());
SqlAggFunction af = (SqlAggFunction) aggFun;
final AggregateRelBase.AggCallBinding binding =
new AggregateRelBase.AggCallBinding(typeFactory, af,
Collections.singletonList(origCall.getType()),
nGroupCols);
// count(any) is always not null, however nullability of sum might
// depend on the number of columns in GROUP BY.
// Here we use SUM0 since we are sure we will not face nullable
// inputs nor we'll face empty set.
aggType = af.inferReturnType(binding);
} else {
aggFun = origCall.getAggregation();
aggType = origCall.getType();
}
AggregateCall newCall =