throw new SemanticException(ErrorMsg.NON_COLLECTION_TYPE.getMsg(expr,
myt.getTypeName()));
}
} else {
// other operators or functions
FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcText);
if (fi == null) {
if (isFunction) {
throw new SemanticException(ErrorMsg.INVALID_FUNCTION
.getMsg((ASTNode) expr.getChild(0)));
} else {
throw new SemanticException(ErrorMsg.INVALID_FUNCTION.getMsg(expr));
}
}
// getGenericUDF() actually clones the UDF. Just call it once and reuse.
GenericUDF genericUDF = fi.getGenericUDF();
if (!fi.isNative()) {
ctx.getUnparseTranslator().addIdentifierTranslation(
(ASTNode) expr.getChild(0));
}
// Handle type casts that may contain type parameters
if (isFunction) {
ASTNode funcNameNode = (ASTNode)expr.getChild(0);
switch (funcNameNode.getType()) {
case HiveParser.TOK_VARCHAR:
// Add type params
VarcharTypeParams varcharTypeParams = new VarcharTypeParams();
varcharTypeParams.length = Integer.valueOf((funcNameNode.getChild(0).getText()));
if (genericUDF != null) {
((SettableUDF)genericUDF).setParams(varcharTypeParams);
}
break;
default:
// Do nothing
break;
}
}
// Detect UDTF's in nested SELECT, GROUP BY, etc as they aren't
// supported
if (fi.getGenericUDTF() != null) {
throw new SemanticException(ErrorMsg.UDTF_INVALID_LOCATION.getMsg());
}
// UDAF in filter condition, group-by caluse, param of funtion, etc.
if (fi.getGenericUDAFResolver() != null) {
if (isFunction) {
throw new SemanticException(ErrorMsg.UDAF_INVALID_LOCATION.
getMsg((ASTNode) expr.getChild(0)));
} else {
throw new SemanticException(ErrorMsg.UDAF_INVALID_LOCATION.getMsg(expr));