Guosmilesmile commented on code in PR #16575:
URL: https://github.com/apache/iceberg/pull/16575#discussion_r3315528887
##########
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:
Introduce a new interface `FileFormatTestSupport` and move
file-format-specific logic into its implementations, such as
`compressionProperties`, `writeRecordsWithoutFieldIds`, and `supportsFeature`.
--
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]