ahmedabu98 commented on code in PR #33315:
URL: https://github.com/apache/beam/pull/33315#discussion_r1894316154
##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/ScanTaskReader.java:
##########
@@ -88,6 +90,7 @@ public boolean advance() throws IOException {
// which are not null-safe.
@SuppressWarnings("nullness")
org.apache.iceberg.@NonNull Schema project = this.project;
+ String nameMapping =
source.getTable().properties().get(TableProperties.DEFAULT_NAME_MAPPING);
Review Comment:
nit
```suggestion
@Nullable String nameMapping =
source.getTable().properties().get(TableProperties.DEFAULT_NAME_MAPPING);
```
##########
sdks/java/io/iceberg/src/test/java/org/apache/beam/sdk/io/iceberg/IcebergIOReadTest.java:
##########
@@ -122,4 +144,131 @@ public void testSimpleScan() throws Exception {
testPipeline.run();
}
+
+ @Test
+ public void testNameMappingScan() throws Exception {
+ org.apache.avro.Schema avroSchema =
+ org.apache.avro.Schema.createRecord(
+ "test",
+ null,
+ null,
+ false,
+ ImmutableList.of(
+ new org.apache.avro.Schema.Field(
+ "data",
org.apache.avro.Schema.create(org.apache.avro.Schema.Type.STRING)),
+ new org.apache.avro.Schema.Field(
+ "id",
org.apache.avro.Schema.create(org.apache.avro.Schema.Type.LONG))));
+
+ List<Map<String, Object>> recordData =
+ ImmutableList.<Map<String, Object>>builder()
+ .add(ImmutableMap.of("id", 0L, "data", "clarification"))
+ .add(ImmutableMap.of("id", 1L, "data", "risky"))
+ .add(ImmutableMap.of("id", 2L, "data", "falafel"))
+ .build();
+
+ List<GenericRecord> avroRecords =
+ recordData.stream()
+ .map(data -> avroGenericRecord(avroSchema, data))
+ .collect(Collectors.toList());
+
+ Configuration hadoopConf = new Configuration();
+ String path = createParquetFile(avroSchema, avroRecords);
+ HadoopInputFile inputFile = HadoopInputFile.fromLocation(path, hadoopConf);
+
+ NameMapping defaultMapping = NameMapping.of(MappedField.of(1, "id"),
MappedField.of(2, "data"));
Review Comment:
can we include a nested field in this test case?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]