You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "huaxingao (via GitHub)" <gi...@apache.org> on 2025/08/05 22:22:48 UTC

Re: [PR] Add golden file tests for vectorized Parquet reads [iceberg]

huaxingao commented on code in PR #13450:
URL: https://github.com/apache/iceberg/pull/13450#discussion_r2255459614


##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/spark/data/vectorized/parquet/TestParquetVectorizedReads.java:
##########
@@ -416,4 +439,60 @@ public void testUuidReads() throws Exception {
     }
     assertRecordsMatch(schema, numRows, data, dataFile, false, BATCH_SIZE);
   }
+
+  private void assertIdenticalFileContents(File actual, File expected, Schema schema)
+      throws IOException {
+    try (CloseableIterable<InternalRow> actualReader =
+        Parquet.read(Files.localInput(actual))
+            .project(schema)
+            .createReaderFunc(t -> SparkParquetReaders.buildReader(schema, t, ID_TO_CONSTANT))
+            .build()) {
+      Iterator<InternalRow> actualIterator = actualReader.iterator();
+      try (CloseableIterable<InternalRow> plainReader =
+          Parquet.read(Files.localInput(expected))
+              .project(schema)
+              .createReaderFunc(t -> SparkParquetReaders.buildReader(schema, t, ID_TO_CONSTANT))
+              .build()) {
+        Iterator<InternalRow> expectedIterator = plainReader.iterator();
+
+        List<InternalRow> expectedList = Lists.newArrayList();
+        expectedIterator.forEachRemaining(expectedList::add);
+        List<InternalRow> actualList = Lists.newArrayList();
+        actualIterator.forEachRemaining(actualList::add);
+
+        assertThat(actualList).isNotEmpty();
+        assertThat(actualList).hasSameSizeAs(expectedList);
+        assertThat(actualList).hasSameElementsAs(expectedList);

Review Comment:
   Nit: Shall we include the `encoding` and `typeName` in the assertion message? That way, it’s easier to identify which pair failed if the test fails
   ```
   assertThat(actualList)
       .as("Validation failed for encoding %s and type %s", encoding, typeName)
       .isNotEmpty()
       .hasSameSizeAs(expectedList)
       .hasSameElementsAs(expectedList);
   ```



-- 
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-unsubscribe@iceberg.apache.org

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


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