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


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/FileGroupRecordBuffer.java:
##########
@@ -316,27 +322,57 @@ protected boolean hasNextBaseRecord(T baseRecord, 
BufferedRecord<T> logRecordInf
       Pair<Boolean, T> isDeleteAndRecord = merge(baseRecordInfo, 
logRecordInfo);
       if (!isDeleteAndRecord.getLeft()) {
         // Updates
-        nextRecord = readerContext.seal(isDeleteAndRecord.getRight());
+        nextRecord = 
readerContext.seal(applyOutputSchemaConversion(isDeleteAndRecord.getRight()));
+        if (baseFileUpdateCallback != null && isDeleteAndRecord.getRight() != 
baseRecord) {
+          // If the record is not the same as the base record, we can emit an 
update
+          handleBaseFileUpdate(logRecordInfo.getRecordKey(), baseRecord, 
nextRecord);
+        }
         readStats.incrementNumUpdates();
         return true;
-      } else if (emitDelete) {
-        // emit Deletes
-        nextRecord = readerContext.getDeleteRow(isDeleteAndRecord.getRight(), 
baseRecordInfo.getRecordKey());
-        readStats.incrementNumDeletes();
-        return nextRecord != null;
       } else {
-        // not emit Deletes
+        // emit Deletes
+        handleBaseFileDelete(logRecordInfo.getRecordKey(), baseRecord);
         readStats.incrementNumDeletes();
-        return false;
+        if (emitDelete) {
+          nextRecord = 
applyOutputSchemaConversion(readerContext.getDeleteRow(isDeleteAndRecord.getRight(),
 baseRecordInfo.getRecordKey()));
+          return nextRecord != null;
+        } else {
+          return false;
+        }
       }
     }
 
     // Inserts
-    nextRecord = readerContext.seal(baseRecord);
+    nextRecord = readerContext.seal(applyOutputSchemaConversion(baseRecord));
     readStats.incrementNumInserts();
     return true;
   }
 
+  /**
+   * Applies the final output schema conversion to the buffered record if 
required. This ensures the records match the requested schema.
+   * @param bufferedRecord the buffered record to convert
+   * @return a new buffered record with the converted record and the proper 
schema ID set
+   */
+  protected BufferedRecord<T> applyOutputSchemaConversion(BufferedRecord<T> 
bufferedRecord) {

Review Comment:
   The projection will remove the record position field if position based 
merging is used. I will move it directly into the new code that handles the 
callback though since I agree the risk outweighs the reward here.



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