pvary commented on code in PR #17610:
URL: https://github.com/apache/iceberg/pull/17610#discussion_r4454127082
##########
data/src/test/java/org/apache/iceberg/data/ReadFormatModelTests.java:
##########
@@ -1450,21 +1487,36 @@ void testPrimitiveDefaultValuesNotApplied(FileFormat
fileFormat) throws IOExcept
@ParameterizedTest
@FieldSource("FILE_FORMATS")
- void testReaderBuilderRecordsPerBatchNotSupported(FileFormat fileFormat)
throws IOException {
- assumeFalse(supportsBatchReads(), engineType().getSimpleName() + "
supports batch reads");
-
+ void testReaderBuilderRecordsPerBatch(FileFormat fileFormat) throws
IOException {
DataGenerator dataGenerator = new DataGenerators.DefaultSchema();
Schema schema = dataGenerator.schema();
- List<Record> genericRecords = dataGenerator.generateRecords();
+ List<Record> genericRecords = dataGenerator.generateRecords(1000);
writeGenericRecords(fileFormat, schema, genericRecords);
InputFile inputFile = encryptedFile.encryptingOutputFile().toInputFile();
- assertThatThrownBy(
- () ->
- FormatModelRegistry.readBuilder(fileFormat, engineType(),
inputFile)
- .recordsPerBatch(100))
- .hasMessageContaining("Batch reading is not supported")
- .isInstanceOf(UnsupportedOperationException.class);
+ if (!supportsBatchReads()) {
+ assertThatThrownBy(
+ () ->
+ FormatModelRegistry.readBuilder(fileFormat, engineType(),
inputFile)
+ .recordsPerBatch(100))
+ .hasMessageContaining("Batch reading is not supported")
+ .isInstanceOf(UnsupportedOperationException.class);
+ return;
+ }
+
+ List<T> readRecords;
+ try (CloseableIterable<T> reader =
+ FormatModelRegistry.readBuilder(fileFormat, engineType(), inputFile)
+ .project(schema)
+ .recordsPerBatch(100)
+ .build()) {
+ readRecords = ImmutableList.copyOf(reader);
+ }
+
+ for (T batch : readRecords) {
+ assertThat(countRows(List.of(batch))).isLessThanOrEqualTo(100);
+ }
+ assertThat(countRows(readRecords)).isEqualTo(genericRecords.size());
Review Comment:
nit: newline
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]