Skip to content

Commit 11952ca

Browse files
committed
[improve](udf) let create udf function error msg more clear (apache#54202)
Problem Summary: sometimes user create function maybe have mistake of parameter so need more clear error msg to know what happend. ``` ERROR 1105 (HY000): errCode = 2, detailMessage = UDF class 'org.apache.doris.udf.AddOne' method 'evaluate' return[java.lang.Integer] type is not supported! before and after of error msg ERROR 1105 (HY000): errCode = 2, detailMessage = UDF class 'org.apache.doris.udf.AddOne' of method 'evaluate' return is [java.lang.Integer] type, but create function command type is STRING ```
1 parent 78fe49a commit 11952ca

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fe/fe-core/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,10 @@ private void checkUdfClass(String clazz, ClassLoader cl) throws ClassNotFoundExc
660660
m -> m.getParameters().length == argsDef.getArgTypes().length).collect(Collectors.toList());
661661
if (evalArgLengthMatchList.size() == 0) {
662662
throw new AnalysisException(
663-
String.format("The number of parameters for method '%s' in class '%s' should be %d",
664-
EVAL_METHOD_KEY, udfClass.getCanonicalName(), argsDef.getArgTypes().length));
663+
String.format(
664+
"The arguments number udf provided and create function command is not equal,"
665+
+ " the parameters of '%s' method in class '%s' maybe should %d.",
666+
EVAL_METHOD_KEY, udfClass.getCanonicalName(), argsDef.getArgTypes().length));
665667
} else if (evalArgLengthMatchList.size() == 1) {
666668
Method method = evalArgLengthMatchList.get(0);
667669
checkUdfType(udfClass, method, returnType.getType(), method.getReturnType(), "return");
@@ -711,19 +713,21 @@ private void checkUdfType(Class clazz, Method method, Type expType, Class pType,
711713
javaTypes = Type.PrimitiveTypeToJavaClassType.get(structType.getPrimitiveType());
712714
} else {
713715
throw new AnalysisException(
714-
String.format("Method '%s' in class '%s' does not support type '%s'",
716+
String.format("Method '%s' in class '%s' does not support type '%s'.",
715717
method.getName(), clazz.getCanonicalName(), expType));
716718
}
717719

718720
if (javaTypes == null) {
719721
throw new AnalysisException(
720-
String.format("Method '%s' in class '%s' does not support type '%s'",
721-
method.getName(), clazz.getCanonicalName(), expType.toString()));
722+
String.format("Method '%s' in class '%s' does not support type '%s'.",
723+
method.getName(), clazz.getCanonicalName(), expType.getPrimitiveType().toString()));
722724
}
723725
if (!javaTypes.contains(pType)) {
724726
throw new AnalysisException(
725-
String.format("UDF class '%s' method '%s' %s[%s] type is not supported!",
726-
clazz.getCanonicalName(), method.getName(), pname, pType.getCanonicalName()));
727+
String.format(
728+
"UDF class '%s' of method '%s' %s is [%s] type, but create function command type is %s.",
729+
clazz.getCanonicalName(), method.getName(), pname, pType.getCanonicalName(),
730+
expType.getPrimitiveType().toString()));
727731
}
728732
}
729733

0 commit comments

Comments
 (0)