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


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/io/storage/row/HoodieRowCreateHandle.java:
##########
@@ -176,15 +178,16 @@ private void writeRow(InternalRow row) {
       //          over again)
       UTF8String[] metaFields = new UTF8String[5];
       UTF8String recordKey = 
row.getUTF8String(HoodieRecord.RECORD_KEY_META_FIELD_ORD);
-      metaFields[3] = 
row.getUTF8String(HoodieRecord.PARTITION_PATH_META_FIELD_ORD);
-      // This is the only meta-field that is generated dynamically, hence 
conversion b/w
-      // [[String]] and [[UTF8String]] is unavoidable if 
preserveHoodieMetadata is false
-      metaFields[1] = shouldPreserveHoodieMetadata ? 
row.getUTF8String(HoodieRecord.COMMIT_SEQNO_METADATA_FIELD_ORD)
-          : 
UTF8String.fromString(seqIdGenerator.apply(GLOBAL_SEQ_NO.getAndIncrement()));
-      metaFields[0] = shouldPreserveHoodieMetadata ? 
row.getUTF8String(HoodieRecord.COMMIT_TIME_METADATA_FIELD_ORD)
-          : commitTime;
-      metaFields[2] = recordKey;
-      metaFields[4] = fileName;
+      metaFields[0] = populateField[0]
+          ? (shouldPreserveHoodieMetadata ? 
row.getUTF8String(HoodieRecord.COMMIT_TIME_METADATA_FIELD_ORD) : commitTime)
+          : null;
+      metaFields[1] = populateField[1]
+          ? (shouldPreserveHoodieMetadata ? 
row.getUTF8String(HoodieRecord.COMMIT_SEQNO_METADATA_FIELD_ORD)
+              : 
UTF8String.fromString(seqIdGenerator.apply(GLOBAL_SEQ_NO.getAndIncrement())))
+          : null;
+      metaFields[2] = populateField[2] ? recordKey : null;
+      metaFields[3] = populateField[3] ? 
row.getUTF8String(HoodieRecord.PARTITION_PATH_META_FIELD_ORD) : null;
+      metaFields[4] = populateField[4] ? fileName : null;

Review Comment:
   should we change the table schema to remove the metadata fields too, cc 
@vinothchandar for visibility.



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