@@ -87,15 +87,16 @@ public CloseableIterator<T> iterator() {
8787
8888 TypeDescription fileSchema = orcFileReader .getSchema ();
8989 final TypeDescription readOrcSchema ;
90+ final TypeDescription fileSchemaWithIds ;
9091 if (ORCSchemaUtil .hasIds (fileSchema )) {
91- readOrcSchema = ORCSchemaUtil . buildOrcProjection ( schema , fileSchema ) ;
92+ fileSchemaWithIds = fileSchema ;
9293 } else {
9394 if (nameMapping == null ) {
9495 nameMapping = MappingUtil .create (schema );
9596 }
96- TypeDescription typeWithIds = ORCSchemaUtil .applyNameMapping (fileSchema , nameMapping );
97- readOrcSchema = ORCSchemaUtil .buildOrcProjection (schema , typeWithIds );
97+ fileSchemaWithIds = ORCSchemaUtil .applyNameMapping (fileSchema , nameMapping );
9898 }
99+ readOrcSchema = ORCSchemaUtil .buildOrcProjection (schema , fileSchemaWithIds );
99100
100101 SearchArgument sarg = null ;
101102 if (filter != null ) {
@@ -125,10 +126,9 @@ public CloseableIterator<T> iterator() {
125126 Schema extraFilterColumns = TypeUtil .select (rowFilter .requiredSchema (), filterColumnIdsNotInReadSchema );
126127 Schema finalReadSchema = TypeUtil .join (schema , extraFilterColumns );
127128
128- TypeDescription finalReadOrcSchema = ORCSchemaUtil .buildOrcProjection (finalReadSchema ,
129- orcFileReader .getSchema ());
129+ TypeDescription finalReadOrcSchema = ORCSchemaUtil .buildOrcProjection (finalReadSchema , fileSchemaWithIds );
130130 TypeDescription rowFilterOrcSchema = ORCSchemaUtil .buildOrcProjection (rowFilter .requiredSchema (),
131- orcFileReader . getSchema () );
131+ fileSchemaWithIds );
132132 RowFilterValueReader filterReader = new RowFilterValueReader (finalReadOrcSchema , rowFilterOrcSchema );
133133
134134 return new OrcRowIterator <>(
0 commit comments