jbonofre commented on code in PR #11839:
URL: https://github.com/apache/iceberg/pull/11839#discussion_r1927420701


##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/data/TestFlinkParquetReader.java:
##########
@@ -199,41 +204,53 @@ public void testTwoLevelList() throws IOException {
     }
   }
 
-  private void writeAndValidate(Iterable<Record> iterable, Schema schema) 
throws IOException {
+  private void writeAndValidate(
+      Iterable<Record> iterable, Schema writeSchema, Schema expectedSchema) 
throws IOException {
     File testFile = File.createTempFile("junit", null, temp.toFile());
     assertThat(testFile.delete()).isTrue();
 
     try (FileAppender<Record> writer =
         Parquet.write(Files.localOutput(testFile))
-            .schema(schema)
+            .schema(writeSchema)
             .createWriterFunc(GenericParquetWriter::buildWriter)
             .build()) {
       writer.addAll(iterable);
     }
 
     try (CloseableIterable<RowData> reader =
         Parquet.read(Files.localInput(testFile))
-            .project(schema)
-            .createReaderFunc(type -> FlinkParquetReaders.buildReader(schema, 
type))
+            .project((expectedSchema != null) ? expectedSchema : writeSchema)
+            .createReaderFunc(
+                type ->
+                    FlinkParquetReaders.buildReader(
+                        (expectedSchema != null) ? expectedSchema : 
writeSchema, type))
             .build()) {
       Iterator<Record> expected = iterable.iterator();
       Iterator<RowData> rows = reader.iterator();
-      LogicalType rowType = FlinkSchemaUtil.convert(schema);
+      LogicalType rowType = FlinkSchemaUtil.convert(writeSchema);
       for (int i = 0; i < NUM_RECORDS; i += 1) {
         assertThat(rows).hasNext();
-        TestHelpers.assertRowData(schema.asStruct(), rowType, expected.next(), 
rows.next());
+        TestHelpers.assertRowData(writeSchema.asStruct(), rowType, 
expected.next(), rows.next());
       }
       assertThat(rows).isExhausted();
     }
   }
 
   @Override
   protected void writeAndValidate(Schema schema) throws IOException {
-    writeAndValidate(RandomGenericData.generate(schema, NUM_RECORDS, 19981), 
schema);
+    writeAndValidate(RandomGenericData.generate(schema, NUM_RECORDS, 19981), 
schema, null);

Review Comment:
   That's a very good suggestion ! Let me do that. Thanks !



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to