HangyuanLiu opened a new issue, #3765:
URL: https://github.com/apache/iceberg-rust/issues/3765
### Is your feature request related to a problem or challenge?
`TableMetadata` has public read accessors for nearly every collection it
holds, such as `schemas_iter()`, `partition_specs_iter()`, `snapshots()`,
`history()`, `metadata_log()`, `sort_orders_iter()`, `properties()` and
`statistics_iter()`. Snapshot references are the exception. The `refs` field is
`pub(crate)`, and the only public read path is `snapshot_for_ref(name)`, which
returns the snapshot that a known reference points to.
That covers a lookup by a name the caller already knows. It does not let a
caller:
- list the branches and tags of a table;
- tell a branch from a tag, or read a reference's retention settings
(`min-snapshots-to-keep`, `max-snapshot-age-ms`, `max-ref-age-ms`).
Code inside the crate reads the map directly; for example, `ExpireSnapshots`
iterates `metadata.refs`. Code outside the crate cannot. Engines that implement
their own snapshot expiration, orphan-file protection, branch and tag
management, a `refs` metadata table, or time travel by reference name need the
complete reference set. Today they have to patch the crate, or serialize the
metadata back to JSON to read the `refs` section.
For comparison, the Java implementation exposes `Table.refs()` and
`TableMetadata.refs()`, both returning `Map<String, SnapshotRef>`.
### Describe the solution you'd like
Add a public, read-only accessor in the same style as the existing ones, for
example:
```rust
/// Returns all snapshot references (branches and tags) of the table.
#[inline]
pub fn refs(&self) -> &HashMap<String, SnapshotReference> {
&self.refs
}
```
This mirrors `properties()`. An iterator form such as `refs_iter()` would
work equally well if it fits the API conventions better.
Would the maintainers be open to exposing `refs` the same way as the other
collections? If so, I'm happy to send a PR with the accessor, documentation and
tests.
### Willingness to contribute
I can contribute to this feature independently
--
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]