SinghAsDev commented on a change in pull request #3774:
URL: https://github.com/apache/iceberg/pull/3774#discussion_r795249047
##########
File path:
parquet/src/main/java/org/apache/iceberg/parquet/ParquetTypeVisitor.java
##########
@@ -66,32 +66,52 @@
Preconditions.checkArgument(list.getFieldCount() == 1,
"Invalid list: does not contain single repeated field: %s", list);
- GroupType repeatedElement = list.getFields().get(0).asGroupType();
+ Type repeatedElement = list.getFields().get(0);
Preconditions.checkArgument(repeatedElement.isRepetition(Type.Repetition.REPEATED),
"Invalid list: inner group is not repeated");
- Preconditions.checkArgument(repeatedElement.getFieldCount() <= 1,
- "Invalid list: repeated group is not a single field: %s", list);
+
+ Type listElement = ParquetSchemaUtil.determineListElementType(list);
+ if (listElement.isRepetition(Type.Repetition.REPEATED)) {
+ return visitTwoLevelList(list, listElement, visitor);
+ } else {
+ return visitThreeLevelList(list, listElement, visitor);
+ }
+ }
+
+ private static <T> T visitTwoLevelList(GroupType list, Type listElement,
ParquetTypeVisitor<T> visitor) {
+ T elementResult = visitListElement(list, listElement, visitor);
+ return visitor.list(list, elementResult);
+ }
+
+ private static <T> T visitThreeLevelList(GroupType list, Type listElement,
ParquetTypeVisitor<T> visitor) {
+ Type repeatedElement = list.getFields().get(0);
Review comment:
I was trying to keep the function signature simple. As the
repeatedElement can be obtained from list easily, I didn't see a reason to add
one more param. Leaving it as is for now, but let me know if you strongly feel
we should pass the `repeatedElement` instead.
--
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]