{
SelectorFactories factories =
SelectorFactories.createFactoriesAndCollectColumnDefinitions(args, cfm, defs);
// resolve built-in functions before user defined functions
Function fun = Functions.get(cfm.ksName, functionName, factories.newInstances(), cfm.ksName, cfm.cfName);
if (fun == null)
throw new InvalidRequestException(String.format("Unknown function '%s'", functionName));
if (fun.returnType() == null)
throw new InvalidRequestException(String.format("Unknown function %s called in selection clause",
functionName));
return AbstractFunctionSelector.newFactory(fun, factories);
}