shanielh opened a new pull request, #3764:
URL: https://github.com/apache/iceberg-rust/pull/3764

   ## Which issue does this PR close?
   
   No tracking issue. Happy to file one if you'd like it for the changelog.
   
   ## What changes are included in this PR?
   
   A manifest writer has no way to record a property of the manifest it writes, 
such as the order of its entries, so that a reader can check it without 
decoding every entry. The Avro header metadata is the natural place for that, 
and Iceberg already writes its own keys there.
   
   This adds `ManifestWriterBuilder::with_header_metadata(key, value)`. It 
writes `key`=`value` into the manifest file's Avro header metadata, beside the 
keys Iceberg writes. Writing the manifest fails if `key` is one Iceberg writes 
(`schema`, `schema-id`, `partition-spec`, `partition-spec-id`, 
`format-version`, `content`) or starts with `avro.`, which apache-avro reserves 
and refuses.
   
   Readers see the keys in the file's Avro header. For now that means 
apache-avro's `Reader::user_metadata`. Once #3762 lands, a `header_metadata()` 
accessor on its `ManifestEntryReader` could expose them; I've left that for a 
follow-up so this PR stands on its own.
   
   This touches the same header-building code as #3763. Whichever lands second 
will need a small merge, and I'll do it.
   
   ## Are these changes tested?
   
   Yes:
   - A manifest written with a custom key has it in its Avro header and still 
parses with `Manifest::parse_avro`.
   - A key Iceberg writes, and an `avro.`-prefixed key, both make writing fail.
   
   `cargo test -p iceberg --lib`, `cargo clippy --all-targets --all-features -- 
-D warnings`, `cargo fmt --check`, `cargo doc` with `-D warnings`, and `cargo 
public-api` (`public-api.txt` updated) all pass.
   
   ## AI Disclosure
   
   I wrote this with Claude Code (Claude Opus 5.5) and reviewed and tested the 
change myself. Places worth a close look:
   - Keys are checked when the manifest is written, not when they are added. 
That keeps `with_header_metadata` chainable like the rest of the builder, but a 
bad key only shows up at `write_manifest_file`.
   - The reserved list is the six keys this writer emits today. A key Iceberg 
starts writing later would need to be added there.
   - Values are strings. Avro header values are bytes, so taking `impl 
AsRef<[u8]>` would be more general, if you prefer that.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to