Li0k commented on code in PR #1115:
URL: https://github.com/apache/iceberg-rust/pull/1115#discussion_r2006970019


##########
crates/iceberg/src/spec/table_metadata_builder.rs:
##########
@@ -1210,6 +1210,35 @@ impl TableMetadataBuilder {
     fn highest_sort_order_id(&self) -> Option<i64> {
         self.metadata.sort_orders.keys().max().copied()
     }
+
+    /// Remove schemas by their ids from the table metadata.
+    /// Does nothing if a schema id is not present. Active schemas should not 
be removed.
+    pub fn remove_schemas(mut self, schema_id_to_remove: &[i32]) -> 
Result<Self> {
+        if schema_id_to_remove.contains(&self.metadata.current_schema_id) {
+            return Err(Error::new(
+                ErrorKind::DataInvalid,
+                "Cannot remove current schema",
+            ));
+        }
+
+        if !schema_id_to_remove.is_empty() {
+            let mut removed_schemas = 
Vec::with_capacity(schema_id_to_remove.len());
+            self.metadata.schemas.retain(|id, _schema| {

Review Comment:
   We should retain the `self.metadata.schemas`



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to