amaliujia commented on a change in pull request #1083: [CALCITE-2889]
IndexOutOfBoundsException thrown if targetTypes[] contains varargs
URL: https://github.com/apache/calcite/pull/1083#discussion_r277910171
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumUtils.java
##########
@@ -211,7 +211,23 @@ static Expression fromInternal(Expression e, Class<?>
targetType) {
List<Expression> expressions) {
final List<Expression> list = new ArrayList<>();
for (int i = 0; i < expressions.size(); i++) {
- list.add(fromInternal(expressions.get(i), targetTypes[i]));
+ if (targetTypes[i].isArray()) {
+ // only the last type could be variable length argument. All left
expressions
Review comment:
Your concern is valid. Now I check if it's checking the last type from
`targetTypes ` as an extra condition to move forward to varargs logic.
Note that only the last type could be varargs. Complier guarantees it. Array
types have values as arrays. So except for varargs, other types (including
array types) are still 1:1 mapped to values.
----------------------------------------------------------------
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