private String aggregateResult(AggregateCall call, PrintWriter pw) { SqlAggFunction aggFunction = call.getAggregation(); String aggregationName = call.getAggregation().getName(); Type ty = typeFactory.getJavaClass(call.getType()); String result; if (aggFunction instanceof SqlUserDefinedAggFunction) { AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function; result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw); } else { List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName); if (typeClasses == null) { throw new UnsupportedOperationException(aggregationName + " Not implemented"); } result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, pw); } return result; }
private void aggregate(AggregateCall call) { SqlAggFunction aggFunction = call.getAggregation(); String aggregationName = call.getAggregation().getName(); Type ty = typeFactory.getJavaClass(call.getType()); if (call.getArgList().size() != 1) { if (aggregationName.equals("COUNT")) { if (call.getArgList().size() != 0) { throw new UnsupportedOperationException("Count with nullable fields"); } } } if (aggFunction instanceof SqlUserDefinedAggFunction) { AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function; doAggregate((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, call.getArgList()); } else { List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName); if (typeClasses == null) { throw new UnsupportedOperationException(aggregationName + " Not implemented"); } doAggregate(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, call.getArgList()); } }