pratyakshsharma commented on a change in pull request #1520: [HUDI-797] Small
performance improvement for rewriting records.
URL: https://github.com/apache/incubator-hudi/pull/1520#discussion_r410171475
##########
File path: hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
##########
@@ -231,6 +254,36 @@ private static GenericRecord rewrite(GenericRecord
record, LinkedHashSet<Field>
return allFields;
}
+ /*
+ * Given a avro record with a given schema, rewrites it into the new schema
while setting fields only from the old
+ * schema.
+ *
+ * NOTE: This function is only suitable if newSchema has fields with the
same position as record's schema.
+ */
+ public static GenericRecord rewriteHoodieRecord(GenericRecord record, Schema
newSchema) {
+ return rewriteHoodieRecord(record, record.getSchema(), newSchema);
Review comment:
Please use getCombinedFieldsToWrite() function here, that will help in
handling schema evolution cases also.
----------------------------------------------------------------
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