CTTY commented on code in PR #2417:
URL: https://github.com/apache/iceberg-rust/pull/2417#discussion_r3230386151


##########
crates/iceberg/src/spec/table_metadata_builder.rs:
##########
@@ -84,6 +86,8 @@ impl TableMetadataBuilder {
         format_version: FormatVersion,
         properties: HashMap<String, String>,
     ) -> Result<Self> {
+        Self::validate_schema_compatible_with_format_version(format_version, 
&schema)?;

Review Comment:
   This is not a good place to validate the schema, how about adding 
`format_version` to `TableMetadataBuilder` and validate the schema in 
`add_schema`?



##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -1565,6 +1574,44 @@ impl Display for FormatVersion {
     }
 }
 
+/// Returns the minimum table format version required by any type in a schema.
+///
+/// Returns [`None`] when the schema contains no type with a specific minimum
+/// table format version requirement.
+pub fn min_format_version_for_schema(schema: &Schema) -> 
Result<Option<FormatVersion>> {
+    visit_schema(schema, &mut MinFormatVersionVisitor)
+}
+
+struct MinFormatVersionVisitor;
+
+impl SchemaVisitor for MinFormatVersionVisitor {

Review Comment:
    After second thoughts, I think iterating thru schema.id_to_field.values() 
will be even simpler



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