Xuanwo commented on code in PR #804: URL: https://github.com/apache/iceberg-rust/pull/804#discussion_r1886370900
########## crates/iceberg/src/catalog/mod.rs: ########## @@ -446,6 +446,12 @@ pub enum TableUpdate { /// Properties to remove removals: Vec<String>, }, + /// Remove partition specs + #[serde(rename_all = "kebab-case")] Review Comment: We don't need `rename_all` here if there are `#[serde(tag = "action", rename_all = "kebab-case")]` for the entire enum. ########## crates/iceberg/src/spec/table_metadata_builder.rs: ########## @@ -740,6 +740,32 @@ impl TableMetadataBuilder { .set_default_partition_spec(Self::LAST_ADDED) } + /// Remove partition specs by their ids from the table metadata. + /// Does nothing if a spec id is not present. + /// + /// If the default partition spec is removed, it is re-added + /// upon build. + pub fn remove_partition_specs(mut self, spec_ids: &[i32]) -> Self { + let mut removed_specs = Vec::with_capacity(spec_ids.len()); + + self.metadata.partition_specs.retain(|k, _| { + if spec_ids.contains(k) { Review Comment: Hi, `spec_ids.contains(k)` is an `O(n)` operation, whereas `partition_specs.get(x)` is `O(1)` (if I remember correctly that `partition_specs` uses a `HashMap`). Do you think it's a good idea to loop through `spec_ids` instead? -- 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