pvary commented on code in PR #16575:
URL: https://github.com/apache/iceberg/pull/16575#discussion_r3311483842
##########
data/src/test/java/org/apache/iceberg/data/BaseFormatModelTests.java:
##########
@@ -2257,4 +2250,167 @@ private void readAndAssertEngineRecords(
assertEquals(
readSchema, convertToEngineRecords(expectedGenericRecords,
readSchema), readRecords);
}
+
+ private DataFile writeEngineRecords(FileFormat fileFormat, Schema schema,
List<T> records)
+ throws IOException {
+ return writeEngineRecords(fileFormat, schema, records, false);
+ }
+
+ private DataFile writeEngineRecords(
+ FileFormat fileFormat, Schema schema, List<T> records, boolean
overwrite) throws IOException {
+ FileWriterBuilder<DataWriter<T>, Object> writerBuilder =
+ FormatModelRegistry.dataWriteBuilder(fileFormat, engineType(),
encryptedFile);
+
+ writerBuilder.schema(schema).spec(PartitionSpec.unpartitioned());
+
+ if (overwrite) {
+ writerBuilder.overwrite();
+ }
+
+ DataWriter<T> writer = writerBuilder.build();
+
+ try (writer) {
+ records.forEach(writer::write);
+ }
+
+ DataFile dataFile = writer.toDataFile();
+ assertThat(dataFile).isNotNull();
+ assertThat(dataFile.recordCount()).isEqualTo(records.size());
+ assertThat(dataFile.format()).isEqualTo(fileFormat);
+
+ return dataFile;
+ }
+
+ private static Reader newOrcReader(InputFile inputFile, Configuration conf)
throws IOException {
Review Comment:
Can we create an interface for the FileFormats to collect these methods?
So every FF needs to implement these for testing, and BaseFormatModelTests
doesn't include file format specific code
--
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]