Github user wuchong commented on a diff in the pull request:
https://github.com/apache/flink/pull/3389#discussion_r103366163
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/utils/ScalarSqlFunction.scala
---
@@ -114,7 +114,9 @@ object ScalarSqlFunction {
inferredTypes.zipWithIndex.foreach {
case (inferredType, i) =>
- operandTypes(i) = inferredType
+ if (operandTypes.length > 0) {
+ operandTypes(i) = inferredType
--- End diff --
If this is a varargs method, the inferredType is an array type. The operand
type should be the component type of the array type, not the array type.
And the `operandTypes.length > 0` condition is still not safe, say the
method is `eval(String a, int... b)` and calling `eval("hello")`, the
`operandTypes`'s length is 1, but `inferredTypes`'s length is 2. An
IndexOutOfBoundsException would be thrown as before.
---
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.
---