-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Parquet] Add support to read Parquet files written with old 2-level list structures. #3774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
222f45e
a84a545
5ee2e4e
d8f0fe8
b4f9c6a
65d624b
9240f6e
bf3d40b
78378de
c44c909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,17 +66,16 @@ private static <T> T visitList(GroupType list, ParquetTypeVisitor<T> visitor) { | |
| 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); | ||
|
SinghAsDev marked this conversation as resolved.
|
||
| 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 elementField = ParquetSchemaUtil.getListElementType(list); | ||
|
|
||
| visitor.beforeRepeatedElement(repeatedElement); | ||
| try { | ||
| T elementResult = null; | ||
| if (repeatedElement.getFieldCount() > 0) { | ||
| Type elementField = repeatedElement.getType(0); | ||
| if (repeatedElement.isPrimitive() || repeatedElement.asGroupType().getFieldCount() > 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes to this class are inconsistent with the changes to the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, addressed this. It would be nice to have some tests to check this behavior. But, I don't think we need to block on that, unless you disagree. |
||
| visitor.beforeElementField(elementField); | ||
| try { | ||
| elementResult = visit(elementField, visitor); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,29 +63,14 @@ public static <T> T visit(org.apache.iceberg.types.Type iType, Type type, TypeWi | |
| Preconditions.checkArgument(group.getFieldCount() == 1, | ||
| "Invalid list: does not contain single repeated field: %s", group); | ||
|
|
||
| GroupType repeatedElement = group.getFields().get(0).asGroupType(); | ||
| Type repeatedElement = group.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", group); | ||
|
|
||
| Types.ListType list = null; | ||
| Types.NestedField element = null; | ||
| if (iType != null) { | ||
| list = iType.asListType(); | ||
| element = list.fields().get(0); | ||
| } | ||
|
|
||
| visitor.fieldNames.push(repeatedElement.getName()); | ||
| try { | ||
| T elementResult = null; | ||
| if (repeatedElement.getFieldCount() > 0) { | ||
| elementResult = visitField(element, repeatedElement.getType(0), visitor); | ||
| } | ||
|
|
||
| return visitor.list(list, group, elementResult); | ||
| } finally { | ||
| visitor.fieldNames.pop(); | ||
| if (ParquetSchemaUtil.isOldListElementType(group)) { | ||
|
SinghAsDev marked this conversation as resolved.
Outdated
|
||
| return visitTwoLevelList(iType, visitor, group, repeatedElement); | ||
| } else { | ||
| return visitThreeLevelList(iType, visitor, group, repeatedElement); | ||
| } | ||
|
|
||
| case MAP: | ||
|
|
@@ -149,6 +134,50 @@ public static <T> T visit(org.apache.iceberg.types.Type iType, Type type, TypeWi | |
| } | ||
| } | ||
|
|
||
| private static <T> T visitTwoLevelList( | ||
| org.apache.iceberg.types.Type iType, | ||
| TypeWithSchemaVisitor<T> visitor, | ||
| GroupType group, | ||
| Type repeatedElement) { | ||
|
SinghAsDev marked this conversation as resolved.
Outdated
|
||
| Types.ListType list = null; | ||
| Types.NestedField element = null; | ||
| if (iType != null) { | ||
| list = iType.asListType(); | ||
|
SinghAsDev marked this conversation as resolved.
Outdated
|
||
| element = list.fields().get(0); | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style: extra newline. Also, we either wrap argument lists at the same level or start all arguments on the next line at 2 indents.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the style used in various parts of code are different. For example, IIUC Let me know which style we should try to follow and I can try to update the intellij-style that we provide with Iceberg repo accordingly. I don't know if it is possible, but I can try.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't worry about where still is incorrect in other places. We'll eventually track those down and fix them, but we do want to keep style from diverging when it is caught by a review. So please do fix this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should already be fixed. Does the update still have style issue? |
||
| T elementResult = visitField(element, repeatedElement, visitor); | ||
| return visitor.list(list, group, elementResult); | ||
| } | ||
|
|
||
| private static <T> T visitThreeLevelList( | ||
| org.apache.iceberg.types.Type iType, | ||
| TypeWithSchemaVisitor<T> visitor, | ||
| GroupType group, | ||
| Type repeatedElement) { | ||
| Preconditions.checkArgument(repeatedElement.asGroupType().getFieldCount() <= 1, | ||
| "Invalid list: repeated group is not a single field: %s", group); | ||
|
|
||
| Types.ListType list = null; | ||
| Types.NestedField element = null; | ||
| if (iType != null) { | ||
| list = iType.asListType(); | ||
| element = list.fields().get(0); | ||
| } | ||
|
|
||
| visitor.fieldNames.push(repeatedElement.getName()); | ||
| try { | ||
| T elementResult = null; | ||
| if (repeatedElement.asGroupType().getFieldCount() > 0) { | ||
| elementResult = visitField(element, repeatedElement.asGroupType().getType(0), visitor); | ||
| } | ||
|
|
||
| return visitor.list(list, group, elementResult); | ||
| } finally { | ||
| visitor.fieldNames.pop(); | ||
| } | ||
| } | ||
|
|
||
| private static <T> T visitField(Types.NestedField iField, Type field, TypeWithSchemaVisitor<T> visitor) { | ||
| visitor.fieldNames.push(field.getName()); | ||
| try { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.