zeroshade commented on code in PR #594:
URL: https://github.com/apache/iceberg-go/pull/594#discussion_r2415002887


##########
table/metadata.go:
##########
@@ -321,6 +325,48 @@ func (b *MetadataBuilder) AddSchema(schema 
*iceberg.Schema) error {
        return nil
 }
 
+// checkSchemaCompatibility checks that the schema is compatible with the 
table's format version.
+// This validates that the schema does not contain types or features that were 
released
+// in later format versions.
+// Java: Schema::checkCompatibility
+func checkSchemaCompatibility(sc *iceberg.Schema, formatVersion int) error {
+       const defaultValuesMinFormatVersion = 3
+       problems := &strings.Builder{}
+
+       fieldsIt, err := sc.FlatFields()
+       if err != nil {
+               return fmt.Errorf("failed to check Schema compatibility: %w", 
err)
+       }
+
+       for _, field := range slices.SortedFunc(fieldsIt, func(a, b 
iceberg.NestedField) int {
+               return cmp.Compare(a.ID, b.ID)
+       }) {
+               colName, found := sc.FindColumnName(field.ID)
+               if !found {
+                       return errors.New("invalid schema: field with id " + 
strconv.Itoa(field.ID) + " not found")
+               }

Review Comment:
   do we actually need this given that we're getting the list of fields from 
the schema directly?



-- 
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]

Reply via email to