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());`?
   
   If it works, it can save us another mapping between hive and flink type 
system, and mappings are hard to keep up to date

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