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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieWriteMergeHandle.java:
##########
@@ -413,7 +418,16 @@ protected void writeToFile(HoodieKey key, HoodieRecord<T> 
record, HoodieSchema s
     if (shouldPreserveRecordMetadata) {
       // NOTE: `FILENAME_METADATA_FIELD` has to be rewritten to correctly 
point to the
       //       file holding this record even in cases when overall metadata is 
preserved
-      HoodieRecord populatedRecord = record.updateMetaField(schema, 
HoodieRecord.FILENAME_META_FIELD_ORD, newFilePath.getName());
+      //
+      // The rewrite is gated on the mode: hoodie.meta.fields.mode is the 
single authority on which
+      // meta columns hold values, and this path would otherwise populate 
_hoodie_file_name on a
+      // COMMIT_TIME_ONLY / NONE table. The value written when the mode opts 
out is an explicit null
+      // rather than a skipped update, because the record being preserved here 
came from the previous
+      // base file — under a narrowed mode it can still carry a file name 
written while the table was
+      // on ALL, and leaving that in place would carry a stale value forward.
+      String fileNameToWrite =

Review Comment:
   no need to update the meta field if `metaFieldsMode.isFileNamePopulated()` 
is false.



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