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


##########
hudi-common/src/main/java/org/apache/hudi/common/model/debezium/AbstractDebeziumAvroPayload.java:
##########
@@ -55,19 +55,26 @@ public AbstractDebeziumAvroPayload(Option<GenericRecord> 
record) {
 
   @Override
   public Option<IndexedRecord> getInsertValue(Schema schema) throws 
IOException {
-    IndexedRecord insertRecord = getInsertRecord(schema);
-    return handleDeleteOperation(insertRecord);
+    Option<IndexedRecord> insertRecord = getInsertRecord(schema);
+    if (!insertRecord.isPresent()) {
+      return insertRecord;
+    }
+    return handleDeleteOperation(insertRecord.get());
   }
 
   @Override
   public Option<IndexedRecord> combineAndGetUpdateValue(IndexedRecord 
currentValue, Schema schema) throws IOException {
     // Step 1: If the time occurrence of the current record in storage is 
higher than the time occurrence of the
     // insert record (including a delete record), pick the current record.
-    if (shouldPickCurrentRecord(currentValue, getInsertRecord(schema), 
schema)) {
-      return Option.of(currentValue);
+    Option<IndexedRecord> indexedRecordOption = getInsertValue(schema);
+    if (indexedRecordOption.isPresent()) {
+      if (shouldPickCurrentRecord(currentValue, getInsertRecord(schema).get(), 
schema)) {
+        return Option.of(currentValue);
+      }
+      // Step 2: Pick the insert record (as a delete record if its a deleted 
event)
+      return getInsertValue(schema);

Review Comment:
   No need to invoke `getInsertValue(schema);` twice, can fallback to line 77 
directly.



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