Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions orc/src/main/java/org/apache/iceberg/orc/ORCSchemaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,6 @@ public static Schema convert(TypeDescription orcSchema) {
public static TypeDescription buildOrcProjection(Schema schema,
TypeDescription originalOrcSchema) {
Map<Integer, OrcField> icebergToOrc = icebergToOrcMapping("root", originalOrcSchema);
if (icebergToOrc.isEmpty()) {
// if no field ids are present in original schema then build mapping from expected schema
// this should ideally be handled at a higher layer with NameMapping
icebergToOrc = icebergToOrcMapping("root", convert(schema));
}
return buildOrcProjection(Integer.MIN_VALUE, schema.asStruct(), true, icebergToOrc);
}

Expand Down
12 changes: 6 additions & 6 deletions orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ public CloseableIterator<T> iterator() {

TypeDescription fileSchema = orcFileReader.getSchema();
final TypeDescription readOrcSchema;
final TypeDescription fileSchemaWithIds;
if (ORCSchemaUtil.hasIds(fileSchema)) {
readOrcSchema = ORCSchemaUtil.buildOrcProjection(schema, fileSchema);
fileSchemaWithIds = fileSchema;
} else {
if (nameMapping == null) {
nameMapping = MappingUtil.create(schema);
}
TypeDescription typeWithIds = ORCSchemaUtil.applyNameMapping(fileSchema, nameMapping);
readOrcSchema = ORCSchemaUtil.buildOrcProjection(schema, typeWithIds);
fileSchemaWithIds = ORCSchemaUtil.applyNameMapping(fileSchema, nameMapping);
}
readOrcSchema = ORCSchemaUtil.buildOrcProjection(schema, fileSchemaWithIds);

SearchArgument sarg = null;
if (filter != null) {
Expand Down Expand Up @@ -125,10 +126,9 @@ public CloseableIterator<T> iterator() {
Schema extraFilterColumns = TypeUtil.select(rowFilter.requiredSchema(), filterColumnIdsNotInReadSchema);
Schema finalReadSchema = TypeUtil.join(schema, extraFilterColumns);

TypeDescription finalReadOrcSchema = ORCSchemaUtil.buildOrcProjection(finalReadSchema,
orcFileReader.getSchema());
TypeDescription finalReadOrcSchema = ORCSchemaUtil.buildOrcProjection(finalReadSchema, fileSchemaWithIds);
TypeDescription rowFilterOrcSchema = ORCSchemaUtil.buildOrcProjection(rowFilter.requiredSchema(),
orcFileReader.getSchema());
fileSchemaWithIds);
RowFilterValueReader filterReader = new RowFilterValueReader(finalReadOrcSchema, rowFilterOrcSchema);

return new OrcRowIterator<>(
Expand Down