c-thiel commented on code in PR #2188:
URL: https://github.com/apache/iceberg-rust/pull/2188#discussion_r3330348842


##########
crates/iceberg/src/spec/schema/mod.rs:
##########
@@ -421,6 +422,56 @@ impl Schema {
     pub fn field_id_to_fields(&self) -> &HashMap<i32, NestedFieldRef> {
         &self.id_to_field
     }
+
+    /// Returns the minimum [`FormatVersion`] required to represent all types 
in this schema.
+    ///
+    /// Iterates over every field and returns the highest minimum version 
among them,
+    /// defaulting to `FormatVersion::V1` if all types are universally 
supported.
+    pub fn min_format_version(&self) -> FormatVersion {
+        self.id_to_field
+            .values()
+            .map(|f| f.field_type.min_format_version())
+            .max()
+            .unwrap_or(FormatVersion::V1)
+    }
+
+    /// Check that all types in this schema are supported by the given format 
version.
+    ///
+    /// Mirrors Java's `Schema.checkCompatibility()`. Returns an error listing 
every

Review Comment:
   The additional check was easy to add. I added it in a separate Commit so its 
easy to revert if it turns out to require more discussions:
   
   
https://github.com/apache/iceberg-rust/pull/2188/commits/abaa8328cc24285b1de99f7088e05946f1b7b480



##########
crates/iceberg/src/spec/schema/mod.rs:
##########
@@ -421,6 +422,56 @@ impl Schema {
     pub fn field_id_to_fields(&self) -> &HashMap<i32, NestedFieldRef> {
         &self.id_to_field
     }
+
+    /// Returns the minimum [`FormatVersion`] required to represent all types 
in this schema.
+    ///
+    /// Iterates over every field and returns the highest minimum version 
among them,
+    /// defaulting to `FormatVersion::V1` if all types are universally 
supported.
+    pub fn min_format_version(&self) -> FormatVersion {
+        self.id_to_field
+            .values()
+            .map(|f| f.field_type.min_format_version())
+            .max()
+            .unwrap_or(FormatVersion::V1)
+    }
+
+    /// Check that all types in this schema are supported by the given format 
version.
+    ///
+    /// Mirrors Java's `Schema.checkCompatibility()`. Returns an error listing 
every

Review Comment:
   Good catch! The additional check was easy to add. I added it in a separate 
Commit so its easy to revert if it turns out to require more discussions:
   
   
https://github.com/apache/iceberg-rust/pull/2188/commits/abaa8328cc24285b1de99f7088e05946f1b7b480



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