-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Parquet: Fixes get null values for the nested field partition column #4627
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 all commits
29451d7
84084b3
a9cf436
43bb36b
630879b
c92776c
630460a
d33fccc
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 |
|---|---|---|
|
|
@@ -140,6 +140,7 @@ public ParquetValueReader<?> struct( | |
| // match the expected struct's order | ||
| Map<Integer, ParquetValueReader<?>> readersById = Maps.newHashMap(); | ||
| Map<Integer, Type> typesById = Maps.newHashMap(); | ||
| Map<Integer, Integer> maxDefinitionLevelsById = Maps.newHashMap(); | ||
| List<Type> fields = struct.getFields(); | ||
| for (int i = 0; i < fields.size(); i += 1) { | ||
| Type fieldType = fields.get(i); | ||
|
|
@@ -148,6 +149,9 @@ public ParquetValueReader<?> struct( | |
| int id = fieldType.getId().intValue(); | ||
|
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. @szehon-ho here the
Member
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! Yea that's ok to me, just in my understanding I'm not entirely sure when it is ever null. Sorry would you be able to change the comment as well to "Defaulting to parent max definition level" or something like that? Otherwise patch looks good to me
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. Updated
Member
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, looks good to me. |
||
| readersById.put(id, ParquetValueReaders.option(fieldType, fieldD, fieldReaders.get(i))); | ||
| typesById.put(id, fieldType); | ||
| if (idToConstant.containsKey(id)) { | ||
| maxDefinitionLevelsById.put(id, fieldD); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -156,11 +160,16 @@ public ParquetValueReader<?> struct( | |
| List<ParquetValueReader<?>> reorderedFields = | ||
| Lists.newArrayListWithExpectedSize(expectedFields.size()); | ||
| List<Type> types = Lists.newArrayListWithExpectedSize(expectedFields.size()); | ||
| // Defaulting to parent max definition level | ||
| int defaultMaxDefinitionLevel = type.getMaxDefinitionLevel(currentPath()); | ||
| for (Types.NestedField field : expectedFields) { | ||
| int id = field.fieldId(); | ||
| if (idToConstant.containsKey(id)) { | ||
| // containsKey is used because the constant may be null | ||
| reorderedFields.add(ParquetValueReaders.constant(idToConstant.get(id))); | ||
| int fieldMaxDefinitionLevel = | ||
| maxDefinitionLevelsById.getOrDefault(id, defaultMaxDefinitionLevel); | ||
| reorderedFields.add( | ||
| ParquetValueReaders.constant(idToConstant.get(id), fieldMaxDefinitionLevel)); | ||
| types.add(null); | ||
| } else if (id == MetadataColumns.ROW_POSITION.fieldId()) { | ||
| reorderedFields.add(ParquetValueReaders.position()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iceberg.spark.source; | ||
|
|
||
| import org.apache.iceberg.relocated.com.google.common.base.MoreObjects; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Objects; | ||
|
|
||
| public class ComplexRecord { | ||
| private long id; | ||
| private NestedRecord struct; | ||
|
|
||
| public ComplexRecord() {} | ||
|
|
||
| public ComplexRecord(long id, NestedRecord struct) { | ||
| this.id = id; | ||
| this.struct = struct; | ||
| } | ||
|
|
||
| public long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(long id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public NestedRecord getStruct() { | ||
| return struct; | ||
| } | ||
|
|
||
| public void setStruct(NestedRecord struct) { | ||
| this.struct = struct; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
|
|
||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
|
|
||
| ComplexRecord record = (ComplexRecord) o; | ||
| return id == record.id && Objects.equal(struct, record.struct); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(id, struct); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return MoreObjects.toStringHelper(this).add("id", id).add("struct", struct).toString(); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.