rdblue commented on a change in pull request #3774:
URL: https://github.com/apache/iceberg/pull/3774#discussion_r794110239



##########
File path: 
parquet/src/main/java/org/apache/iceberg/parquet/ParquetSchemaUtil.java
##########
@@ -164,4 +165,62 @@ public Boolean primitive(PrimitiveType primitive) {
     }
   }
 
+  public static Type determineListElementType(GroupType array) {
+    Type repeated = array.getFields().get(0);
+    boolean isOldListElementType = isOldListElementType(array);
+
+    Preconditions.checkArgument(isOldListElementType ||
+            repeated.asGroupType().getFieldCount() <= 1,
+        "Invalid list: repeated group is not a single field: %s", array);
+
+    return isOldListElementType ? repeated : repeated.asGroupType().getType(0);

Review comment:
       Before, the visitor checked that the repeated group had at least 1 
field. That prevented this from throwing `NoSuchElementException`.
   
   However, there are plenty of other places that just assumed that there would 
be a field and would call `getType(0)` without checking, so I think that 
leaving it out is okay. That means that we no longer need the check to make 
sure there is at least one field in the visitor.




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