Github user KurtYoung commented on a diff in the pull request:
https://github.com/apache/flink/pull/3389#discussion_r104614583
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/utils/UserDefinedFunctionUtils.scala
---
@@ -94,23 +94,28 @@ object UserDefinedFunctionUtils {
val evalMethods = checkAndExtractEvalMethods(function)
val filtered = evalMethods
- // go over all eval methods and find one matching
- .filter { cur =>
- val signatures = cur.getParameterTypes
- // match parameters of signature to actual parameters
- (actualSignature.length >= signatures.length &&
- actualSignature.zipWithIndex.forall { case (clazz, i) =>
- (i < signatures.length && parameterTypeEquals(clazz,
signatures(i))) ||
- (i >= signatures.length - 1 && cur.isVarArgs &&
+ // go over all eval methods and filter out one and only one matching
+ .filter {
+ case cur if !cur.isVarArgs =>
+ val signatures = cur.getParameterTypes
+ // match parameters of signature to actual par(ameters
+ actualSignature.length == signatures.length &&
+ signatures.zipWithIndex.forall { case (clazz, i) =>
+ parameterTypeEquals(actualSignature(i), clazz)
+ }
+ case cur if cur.isVarArgs =>
+ val signatures = cur.getParameterTypes
+ actualSignature.zipWithIndex.forall { case (clazz, i) =>
+ (i < signatures.length - 1 &&
--- End diff --
we can also move the condition check about `i` into case pattern to make
the codes more clear, like:
```
case (clazz, i) if (i < signatures.length - 1 ) =>
// ...
case (clazz, i) if (i >= signatures.length - 1) =>
// ...
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---