wuchong commented on code in PR #19283:
URL: https://github.com/apache/flink/pull/19283#discussion_r934209127
##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/conversion/HiveInspectors.java:
##########
@@ -435,23 +438,28 @@ public static Object toFlinkObject(ObjectInspector
inspector, Object data, HiveS
List<? extends StructField> fields =
structInspector.getAllStructFieldRefs();
- Row row = new Row(fields.size());
+ final Object[] fieldByPosition = new Object[fields.size()];
+
+ LinkedHashMap<String, Integer> positionByName = new
LinkedHashMap<>();
// StandardStructObjectInspector.getStructFieldData in Hive-1.2.1
only accepts array or
// list as data
if (!data.getClass().isArray()
&& !(data instanceof List)
&& (inspector instanceof StandardStructObjectInspector)) {
data = new Object[] {data};
}
- for (int i = 0; i < row.getArity(); i++) {
- row.setField(
- i,
+ for (int i = 0; i < fields.size(); i++) {
+ StructField field = fields.get(i);
+ fieldByPosition[i] =
toFlinkObject(
- fields.get(i).getFieldObjectInspector(),
- structInspector.getStructFieldData(data,
fields.get(i)),
- hiveShim));
+ field.getFieldObjectInspector(),
+ structInspector.getStructFieldData(data,
field),
+ hiveShim);
+ positionByName.put(field.getFieldName(), i);
}
- return row;
+
+ return RowUtils.createRowWithNamedPositions(
Review Comment:
Is it necessary to create a name-based Row?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]