Fokko commented on code in PR #12887:
URL: https://github.com/apache/iceberg/pull/12887#discussion_r2057748766


##########
api/src/main/java/org/apache/iceberg/PartitionSpec.java:
##########
@@ -644,6 +646,16 @@ static void checkCompatibility(PartitionSpec spec, Schema 
schema) {
             "Invalid source type %s for transform: %s",
             sourceType,
             transform);
+        // The only valid parent types for a PartitionField are StructTypes. 
This must be checked
+        // recursively.
+        int fieldId = field.sourceId();
+        Integer parentId;
+        while ((parentId = parents.get(fieldId)) != null) {
+          Type parentType = schema.findType(parentId);
+          ValidationException.check(
+              parentType.isStructType(), "Invalid partition field parent: %s", 
parentType);
+          fieldId = parentId;
+        }

Review Comment:
   Nit, I think this is easier to read:
   ```suggestion
           Integer parentId = parents.get(fieldId);
           while (parentId != null) {
             Type parentType = schema.findType(parentId);
             ValidationException.check(
                 parentType.isStructType(), "Invalid partition field parent: 
%s", parentType);
             parentId =  parents.get(parentId);
           }
   ```



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to