xiarixiaoyao commented on a change in pull request #4910:
URL: https://github.com/apache/hudi/pull/4910#discussion_r830505261
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/table/log/AbstractHoodieLogRecordReader.java
##########
@@ -361,15 +372,38 @@ private boolean isNewInstantBlock(HoodieLogBlock
logBlock) {
*/
private void processDataBlock(HoodieDataBlock dataBlock,
Option<List<String>> keys) throws Exception {
try (ClosableIterator<IndexedRecord> recordItr =
dataBlock.getRecordItr(keys.orElse(Collections.emptyList()))) {
+ boolean headRecord = true;
+ Option<Schema> schemaOption = Option.empty();
while (recordItr.hasNext()) {
- IndexedRecord record = recordItr.next();
+ IndexedRecord currentRecord = recordItr.next();
+ if (headRecord) {
+ schemaOption = getMergedSchema(dataBlock, currentRecord);
+ headRecord = false;
+ }
+ IndexedRecord record = schemaOption.isPresent() ?
AvroSchemaUtil.rewriteRecord(currentRecord, schemaOption.get()) : currentRecord;
processNextRecord(createHoodieRecord(record,
this.hoodieTableMetaClient.getTableConfig(), this.payloadClassFQN,
this.preCombineField, this.withOperationField,
this.simpleKeyGenFields, this.partitionName));
totalLogRecords.incrementAndGet();
}
}
}
+ private Option<Schema> getMergedSchema(HoodieDataBlock dataBlock,
IndexedRecord record) {
Review comment:
added
--
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]