Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ public void close() throws IOException, InterruptedException {
}
finalMetadata.putAll(finalWriteContext.getExtraMetaData());
parquetFileWriter.end(finalMetadata);
AutoCloseables.uncheckedClose(parquetFileWriter);
} finally {
AutoCloseables.uncheckedClose(columnStore, pageStore, bloomFilterWriteStore, parquetFileWriter);
AutoCloseables.uncheckedClose(columnStore, pageStore, bloomFilterWriteStore);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have ParquetFileWriter to handle the "aborted" state, this change can be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I haven't finish my change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, then. I was too fast. 😄
Ping me when you're ready.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick review!

closed = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,4 +780,44 @@ public void testParquetWriterBuilderCanNotConfigurePathAndFile() throws IOExcept
"Cannot set both path and file", IllegalStateException.class, (Callable<ParquetWriter<Group>>) () ->
ExampleParquetWriter.builder(path).withFile(outputFile).build());
}

@Test
public void testNoFlushAfterException() throws Exception {
final File testDir = temp.newFile();
testDir.delete();

final Path file = new Path(testDir.getAbsolutePath(), "test.parquet");

MessageType schema = Types.buildMessage()
.required(BINARY)
.named("binary_field")
.required(INT32)
.named("int32_field")
.named("test_schema_abort");
Configuration conf = new Configuration();

try (ParquetWriter<Group> writer = ExampleParquetWriter.builder(new Path(file.toString()))
.withAllocator(allocator)
.withType(schema)
.build()) {

SimpleGroupFactory f = new SimpleGroupFactory(schema);
writer.write(f.newGroup()
.append("binary_field", "hello")
.append("int32_field", 123));

Field internalWriterField = ParquetWriter.class.getDeclaredField("writer");
internalWriterField.setAccessible(true);
Object internalWriter = internalWriterField.get(writer);

Field abortedField = internalWriter.getClass().getDeclaredField("aborted");
abortedField.setAccessible(true);
abortedField.setBoolean(internalWriter, true);
writer.close();
}

// After closing, check whether file exists or is empty
FileSystem fs = file.getFileSystem(conf);
assertTrue(!fs.exists(file) || fs.getFileStatus(file).getLen() == 0);
}
}
Loading