nastra commented on code in PR #3662:
URL: https://github.com/apache/parquet-java/pull/3662#discussion_r3628559470
##########
parquet-hadoop/src/test/java/org/apache/parquet/hadoop/rewrite/ParquetRewriterTest.java:
##########
@@ -689,6 +691,84 @@ public void testMergeTwoFilesNullifyAndRenamedSameColumn()
throws Exception {
.hasMessage("Cannot nullify and rename the same column");
}
+ @Test
+ public void testInputFileReadersClosedWhenLaterInputFileFailsToOpen() throws
Exception {
+ MessageType schema = new MessageType("schema", new PrimitiveType(OPTIONAL,
INT64, "DocId"));
+ EncryptionTestFile file = new TestFileBuilder(conf, schema)
+ .withNumRecord(numRecord)
+ .withCodec("UNCOMPRESSED")
+ .withPageSize(ParquetProperties.DEFAULT_PAGE_SIZE)
+ .withWriterVersion(writerVersion)
+ .build();
+
+ CloseRecordingInputFile openable =
+ new CloseRecordingInputFile(HadoopInputFile.fromPath(new
Path(file.getFileName()), conf));
+ InputFile failing = new InputFile() {
+ @Override
+ public long getLength() {
+ return 0;
+ }
+
+ @Override
+ public SeekableInputStream newStream() throws IOException {
+ throw new IOException("simulated open failure");
+ }
+ };
+
+ OutputFile output = HadoopOutputFile.fromPath(new Path(outputFile), conf);
+ RewriteOptions options =
+ new RewriteOptions.Builder(parquetConf, Arrays.asList(openable,
failing), output).build();
+
+ assertThrows(IllegalArgumentException.class, () -> new
ParquetRewriter(options));
Review Comment:
can you please rebase the PR and use AssertJ assertions? This would be
something like `assertThatThrownBy(() -> new
ParquetRewriter(options)).isInstanceOf(IllegalArgumentException.class).hasMessage(...)`.
The other one would be a simple
`assertThat(openable.isStreamClosed()).isTrue()`
--
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]