michaelmior commented on a change in pull request #1319: [CALCITE-3195] Handle
UDF that throws checked exceptions in enumerable code generator
URL: https://github.com/apache/calcite/pull/1319#discussion_r306312190
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/ReflectiveCallNotNullImplementor.java
##########
@@ -47,17 +47,34 @@ public Expression implement(RexToLixTranslator translator,
RexCall call, List<Expression> translatedOperands) {
translatedOperands =
EnumUtils.fromInternal(method.getParameterTypes(), translatedOperands);
+ final Expression callExpr;
if ((method.getModifiers() & Modifier.STATIC) != 0) {
- return Expressions.call(method, translatedOperands);
+ callExpr = Expressions.call(method, translatedOperands);
} else {
// The UDF class must have a public zero-args constructor.
// Assume that the validator checked already.
final Expression target =
Expressions.new_(method.getDeclaringClass());
- return Expressions.call(target, method, translatedOperands);
+ callExpr = Expressions.call(target, method, translatedOperands);
}
+ if (!containsCheckedException(method)) {
+ return callExpr;
+ }
+ return translator.handleMethodCheckedExceptions(callExpr);
}
+ private boolean containsCheckedException(Method method) {
+ Class[] exceptions = method.getExceptionTypes();
+ if (exceptions == null || exceptions.length == 0) {
+ return false;
+ }
+ for (Class clazz: exceptions) {
Review comment:
Sorry this is getting really nitpicky, but there should be a space on either
side of the `:`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services