xuefuz 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_r336574147
 
 

 ##########
 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:
   Maybe I missed something, but Array.newInstance() needs a Class, while 
toFlinkObject() returns an Object, right?

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

Reply via email to