the-other-tim-brown commented on code in PR #13742:
URL: https://github.com/apache/hudi/pull/13742#discussion_r2302481535


##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieAvroRecordMerger.java:
##########
@@ -43,9 +44,35 @@ public String getMergingStrategy() {
   }
 
   @Override
-  public Option<Pair<HoodieRecord, Schema>> merge(HoodieRecord older, Schema 
oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws 
IOException {
-    return combineAndGetUpdateValue(older, newer, oldSchema, newSchema, props)
-        .map(r -> Pair.of(new HoodieAvroIndexedRecord(r), r.getSchema()));
+  public Pair<HoodieRecord, Schema> merge(HoodieRecord older, Schema 
oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws 
IOException {
+    Option<IndexedRecord> previousAvroData = older.toIndexedRecord(oldSchema, 
props).map(HoodieAvroIndexedRecord::getData);
+    HoodieRecordPayload payload = ((HoodieAvroRecord) newer).getData();
+    Option<IndexedRecord> updatedValue;
+    Comparable orderingVal;
+    if (previousAvroData.isEmpty()) {
+      updatedValue = payload.getInsertValue(newSchema, props);
+      orderingVal = payload.getOrderingValue();
+    } else {
+      updatedValue = ((HoodieAvroRecord) 
newer).getData().combineAndGetUpdateValue(previousAvroData.get(), newSchema, 
props);

Review Comment:
   The newer record should not be a null object. It is possible that the 
underlying data field is null if it is a delete.



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