This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 55e181e3 chore: expose field id mapping from schema (#1498)
55e181e3 is described below
commit 55e181e3d9307b8d36dd2321109201cb3483772b
Author: dentiny <[email protected]>
AuthorDate: Mon Jul 14 02:07:57 2025 -0700
chore: expose field id mapping from schema (#1498)
## What changes are included in this PR?
Motivation:
- I would like to leverage naming mapping, to compensate the issue that
table metadata reassigns field id on creation.
- Name mapping requires (1) field id; (2) field name; (3) children
values; all these information could be fetched from `Schema`, but could
be a lot easier and performant if we could expose (1) field id -> field
name; (2) field id -> field mapping.
## Are these changes tested?
N/A, trivial visibility change, no functional change
---
crates/iceberg/src/spec/schema/mod.rs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/crates/iceberg/src/spec/schema/mod.rs
b/crates/iceberg/src/spec/schema/mod.rs
index b1afa62c..5c677a59 100644
--- a/crates/iceberg/src/spec/schema/mod.rs
+++ b/crates/iceberg/src/spec/schema/mod.rs
@@ -410,9 +410,14 @@ impl Schema {
}
/// Return A HashMap matching field ids to field names.
- pub(crate) fn field_id_to_name_map(&self) -> &HashMap<i32, String> {
+ pub fn field_id_to_name_map(&self) -> &HashMap<i32, String> {
&self.id_to_name
}
+
+ /// Return a hashmap matching field ids to nested fields.
+ pub fn field_id_to_fields(&self) -> &HashMap<i32, NestedFieldRef> {
+ &self.id_to_field
+ }
}
impl Display for Schema {