You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/03/06 08:09:35 UTC

[GitHub] [calcite] zabetak commented on a change in pull request #1083: [CALCITE-2889] IndexOutOfBoundsException thrown if targetTypes[] contains varargs

zabetak 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_r262828512
 
 

 ##########
 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
+        // are supposed to be the same type as targetTypes[i].getComponentType().
+        List<Expression> subList = expressions.subList(i, expressions.size());
+        list.addAll(fromInternal(targetTypes[i].getComponentType(), subList));
+        break;
+      } else {
+        list.add(fromInternal(expressions.get(i), targetTypes[i]));
+      }
+    }
+    return list;
+  }
+
+  static List<Expression> fromInternal(Class<?> targetType, List<Expression> expressions) {
 
 Review comment:
   Does it need to be package private? Can't we make it just private?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services