danny0405 commented on code in PR #17604:
URL: https://github.com/apache/hudi/pull/17604#discussion_r2757014933


##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HiveRecordContext.java:
##########
@@ -97,16 +104,37 @@ public HoodieRecord<ArrayWritable> 
constructHoodieRecord(BufferedRecord<ArrayWri
 
   @Override
   public ArrayWritable constructEngineRecord(HoodieSchema recordSchema, 
Object[] fieldValues) {
-    return new ArrayWritable(Writable.class, (Writable[]) fieldValues);
+    Schema avroSchema = recordSchema.toAvroSchema();

Review Comment:
   can we ensure the fieldValues as Writable in the invoker instead of add the 
conversion here? can we avoid to introduce per-row for-loop if possible to 
avoid performance regression.



##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/HiveRecordContext.java:
##########
@@ -97,16 +104,37 @@ public HoodieRecord<ArrayWritable> 
constructHoodieRecord(BufferedRecord<ArrayWri
 
   @Override
   public ArrayWritable constructEngineRecord(HoodieSchema recordSchema, 
Object[] fieldValues) {
-    return new ArrayWritable(Writable.class, (Writable[]) fieldValues);
+    Schema avroSchema = recordSchema.toAvroSchema();
+    List<Schema.Field> fields = avroSchema.getFields();
+    Writable[] writables = new Writable[fields.size()];
+    for (int i = 0; i < fields.size(); i++) {
+      Schema fieldSchema = resolveUnion(fields.get(i).schema());
+      writables[i] = convertToWritable(fieldSchema, fieldValues[i]);
+    }
+    return new ArrayWritable(Writable.class, writables);
   }
 
   @Override
   public ArrayWritable mergeWithEngineRecord(HoodieSchema schema,
                                              Map<Integer, Object> updateValues,
                                              BufferedRecord<ArrayWritable> 
baseRecord) {
     Writable[] engineRecord = baseRecord.getRecord().get();
+    Schema avroSchema = schema.toAvroSchema();

Review Comment:
   ditto



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

Reply via email to