prashantwason commented on code in PR #18384:
URL: https://github.com/apache/hudi/pull/18384#discussion_r3011287897
##########
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:
Yes, that's correct. The meta field columns remain in the schema for
compatibility. When a field is excluded, its value is written as null (which in
Parquet takes zero data bytes — stored only as a bit flag in the definition
level). This preserves schema consistency while saving storage for fields that
can be virtualized (e.g. record_key, partition_path, file_name).
--
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]