You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/10/18 13:52:40 UTC
[GitHub] [flink] bowenli86 commented on a change in pull request #9927:
[FLINK-14397][hive] Failed to run Hive UDTF with array arguments
bowenli86 commented on a change in pull request #9927: [FLINK-14397][hive] Failed to run Hive UDTF with array arguments
URL: https://github.com/apache/flink/pull/9927#discussion_r336499773
##########
File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/conversion/HiveInspectors.java
##########
@@ -312,9 +313,11 @@ public static Object toFlinkObject(ObjectInspector inspector, Object data) {
ListObjectInspector listInspector = (ListObjectInspector) inspector;
List<?> list = listInspector.getList(data);
- Object[] result = new Object[list.size()];
+ // flink expects a specific array type (e.g. Integer[] instead of Object[]), so we have to get the element class
+ ObjectInspector elementInspector = listInspector.getListElementObjectInspector();
+ Object[] result = (Object[]) Array.newInstance(classForObjectInspector(elementInspector), list.size());
Review comment:
with the assumption we discussed in mind, seems that we can just call `Object[] result = (Object[]) Array.newInstance(toFlinkObject(elementInspector, list.get(0).getClass()), list.size());`?
----------------------------------------------------------------
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