block.setHasGrouping();
return new AggregationFunctionCallEval(countRows, (AggFunction) countRows.newInstance(),
new EvalNode[] {});
} catch (InternalException e) {
throw new UndefinedFunctionException(CatalogUtil.
getCanonicalName(countRows.getSignature(), new DataType[]{}));
}
}
case GeneralSetFunction: {
GeneralSetFunctionExpr setFunction = (GeneralSetFunctionExpr) expr;
Expr[] params = setFunction.getParams();
EvalNode[] givenArgs = new EvalNode[params.length];
DataType[] paramTypes = new DataType[params.length];
FunctionType functionType = setFunction.isDistinct() ?
FunctionType.DISTINCT_AGGREGATION : FunctionType.AGGREGATION;
givenArgs[0] = createEvalTree(plan, block, params[0]);
if (setFunction.getSignature().equalsIgnoreCase("count")) {
paramTypes[0] = CatalogUtil.newSimpleDataType(TajoDataTypes.Type.ANY);
} else {
paramTypes[0] = givenArgs[0].getValueType();
}
if (!catalog.containFunction(setFunction.getSignature(), functionType, paramTypes)) {
throw new UndefinedFunctionException(CatalogUtil. getCanonicalName(setFunction.getSignature(), paramTypes));
}
FunctionDesc funcDesc = catalog.getFunction(setFunction.getSignature(), functionType, paramTypes);
if (!block.hasGroupbyNode()) {
block.setHasGrouping();
}
try {
return new AggregationFunctionCallEval(funcDesc, (AggFunction) funcDesc.newInstance(), givenArgs);
} catch (InternalException e) {
e.printStackTrace();
}
}
break;
case Function:
FunctionExpr function = (FunctionExpr) expr;
// Given parameters
Expr[] params = function.getParams();
EvalNode[] givenArgs = new EvalNode[params.length];
DataType[] paramTypes = new DataType[params.length];
for (int i = 0; i < params.length; i++) {
givenArgs[i] = createEvalTree(plan, block, params[i]);
paramTypes[i] = givenArgs[i].getValueType();
}
if (!catalog.containFunction(function.getSignature(), paramTypes)) {
throw new UndefinedFunctionException(CatalogUtil.getCanonicalName(function.getSignature(), paramTypes));
}
FunctionDesc funcDesc = catalog.getFunction(function.getSignature(), paramTypes);
try {