nssalian commented on code in PR #2188:
URL: https://github.com/apache/iceberg-rust/pull/2188#discussion_r3326627871


##########
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:
   Accuracy fix on the doc comment: this says it "Mirrors Java's 
Schema.checkCompatibility()", but Java's version also rejects a non-null 
initial-default when formatVersion < 3, which isn't checked here (iceberg-go 
[#932](https://github.com/apache/iceberg-go/pull/932) guards variant defaults 
too). Could we narrow it to "Mirrors the type-version portion of Java's 
Schema.checkCompatibility()" so it doesn't read as full parity? Adding the 
actual default check is fine as a follow-up.



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