zeroshade commented on code in PR #567:
URL: https://github.com/apache/iceberg-go/pull/567#discussion_r2360564197
##########
table/metadata.go:
##########
@@ -871,6 +890,35 @@ func (b *MetadataBuilder) RemovePartitionSpecs(ints []int)
error {
return nil
}
+func (b *MetadataBuilder) RemoveSchemas(ints []int) error {
+ if len(ints) == 0 {
+ return nil
+ }
+
+ if slices.Contains(ints, b.currentSchemaID) {
+ return fmt.Errorf("can't remove current schema with id %d",
b.currentSchemaID)
+ }
+
+ newSchemas := make([]*iceberg.Schema, 0, len(b.schemaList)-len(ints))
+ removed := make([]int, len(ints))
+ for _, schema := range b.schemaList {
+ if slices.Contains(ints, schema.ID) {
+ removed = append(removed, schema.ID)
+
+ continue
+ }
+ newSchemas = append(newSchemas, schema)
+ }
Review Comment:
we might be able to simplify this a bit:
```go
b.schemaList = slices.DeleteFunc(b.schemaList, func(s *iceberg.Schema) bool {
if slices.Contains(ints, schema.ID) {
removed = append(removed, schema.ID)
return true
}
return false
})
```
--
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]