edgarRd commented on a change in pull request #1208:
URL: https://github.com/apache/iceberg/pull/1208#discussion_r461305817
##########
File path:
orc/src/test/java/org/apache/iceberg/orc/TestExpressionToSearchArgument.java
##########
@@ -262,4 +264,65 @@ public void testEvolvedSchema() {
actual = ExpressionToSearchArgument.convert(boundFilter, readSchema);
Assert.assertEquals(expected.toString(), actual.toString());
}
+
+ @Test
+ public void testOriginalSchemaNameMapping() {
+ Schema originalSchema = new Schema(
+ required(1, "int", Types.IntegerType.get()),
+ optional(2, "long", Types.LongType.get())
+ );
+
+ TypeDescription orcSchemaWithoutIds =
ORCSchemaUtil.removeIds(ORCSchemaUtil.convert(originalSchema));
+ NameMapping nameMapping = MappingUtil.create(originalSchema);
+
+ TypeDescription readSchema =
ORCSchemaUtil.buildOrcProjection(originalSchema,
+ ORCSchemaUtil.applyNameMapping(orcSchemaWithoutIds, nameMapping));
+
+ Expression expr = and(equal("int", 1), equal("long", 1));
+ Expression boundFilter = Binder.bind(originalSchema.asStruct(), expr,
true);
+ SearchArgument expected = SearchArgumentFactory.newBuilder()
+ .equals("`int`", Type.LONG, 1L)
+ .equals("`long`", Type.LONG, 1L)
+ .build();
+
+ SearchArgument actual = ExpressionToSearchArgument.convert(boundFilter,
readSchema);
+ Assert.assertEquals(expected.toString(), actual.toString());
+ }
+
+ @Test
+ public void testModifiedSchemaNameMapping() {
Review comment:
I've added a couple tests to address this.
##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcIterable.java
##########
@@ -51,14 +54,16 @@
private final boolean caseSensitive;
private final Function<TypeDescription, OrcBatchReader<?>>
batchReaderFunction;
private final int recordsPerBatch;
+ private final NameMapping nameMapping;
OrcIterable(InputFile file, Configuration config, Schema schema,
- Long start, Long length,
+ NameMapping nameMapping, Long start, Long length,
Function<TypeDescription, OrcRowReader<?>> readerFunction,
boolean caseSensitive, Expression filter,
Function<TypeDescription, OrcBatchReader<?>>
batchReaderFunction, int recordsPerBatch) {
this.schema = schema;
this.readerFunction = readerFunction;
this.file = file;
+ this.nameMapping =
Optional.ofNullable(nameMapping).orElse(MappingUtil.create(schema));
Review comment:
Done.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]