wombatu-kun commented on code in PR #18375:
URL: https://github.com/apache/hudi/pull/18375#discussion_r3035482138
##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/UpdateProcessor.java:
##########
@@ -136,18 +140,43 @@ protected BufferedRecord<T>
handleNonDeletes(BufferedRecord<T> previousRecord, B
// special case for payloads when there is no previous record
HoodieSchema recordSchema =
readerContext.getRecordContext().decodeAvroSchema(mergedRecord.getSchemaId());
GenericRecord record =
readerContext.getRecordContext().convertToAvroRecord(mergedRecord.getRecord(),
recordSchema);
- HoodieAvroRecord hoodieRecord = new HoodieAvroRecord<>(null,
HoodieRecordUtils.loadPayload(payloadClass, record,
mergedRecord.getOrderingValue()));
- try {
- if (hoodieRecord.shouldIgnore(recordSchema, properties)) {
- return null;
- } else {
- HoodieSchema readerSchema =
readerContext.getSchemaHandler().getRequestedSchema();
- // If the record schema is different from the reader schema,
rewrite the record using the payload methods to ensure consistency with legacy
writer paths
- hoodieRecord.rewriteRecordWithNewSchema(recordSchema, properties,
readerSchema).toIndexedRecord(readerSchema, properties)
- .ifPresent(rewrittenRecord ->
mergedRecord.replaceRecord(readerContext.getRecordContext().convertAvroRecord(rewrittenRecord.getData())));
+ Schema recordAvroSchema = recordSchema.toAvroSchema();
+
+ // If convertToAvroRecord returned a cached record with a different
schema (e.g., from
+ // extractDataFromRecord caching for ExpressionPayload in the COW
write path), the record
+ // is already in write-schema format with correctly evaluated
expressions. Convert directly.
+ // Note: SENTINEL records have null schema and must go through the
payload path for shouldIgnore.
Review Comment:
Safe — SENTINEL records always have `null` schema
(`HoodieRecord.EmptyRecord.getSchema()` returns null), so the
`record.getSchema() != null` guard prevents them from entering this branch.
Strengthened the comment to make this invariant explicit.
--
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]