From b7f3c094ff99dd69be33ffbfc5a09abc00645ee1 Mon Sep 17 00:00:00 2001 From: Christian Thiel Date: Mon, 27 May 2024 15:48:40 +0200 Subject: [PATCH] Add schema into_builder --- crates/iceberg/src/spec/schema.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/iceberg/src/spec/schema.rs b/crates/iceberg/src/spec/schema.rs index 2dc9c4dd1..e59712e8e 100644 --- a/crates/iceberg/src/spec/schema.rs +++ b/crates/iceberg/src/spec/schema.rs @@ -269,6 +269,16 @@ impl Schema { } } + /// Create a new schema builder from a schema. + pub fn into_builder(self) -> SchemaBuilder { + SchemaBuilder { + schema_id: self.schema_id, + fields: self.r#struct.fields().iter().cloned().collect(), + alias_to_id: self.alias_to_id, + identifier_field_ids: self.identifier_field_ids, + } + } + /// Get field by field id. pub fn field_by_id(&self, field_id: i32) -> Option<&NestedFieldRef> { self.id_to_field.get(&field_id)