Skip to content

Commit b57bfe3

Browse files
committed
fixes
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 0907587 commit b57bfe3

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

java/vortex-jni/src/test/java/dev/vortex/jni/JNIWriterTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ public void testCreateWriterPlainLocalPath() throws IOException {
8484
assertTrue(Files.exists(outputPath), "output file should exist");
8585
}
8686

87+
@Test
88+
public void testCreateWriterCreatesParentDirectories() throws IOException {
89+
Path outputPath = tempDir.resolve("nested/sub/dir/test_create_nested.vortex");
90+
String writePath = outputPath.toAbsolutePath().toUri().toString();
91+
92+
BufferAllocator allocator = ArrowAllocation.rootAllocator();
93+
Map<String, String> options = new HashMap<>();
94+
95+
Session session = Session.create();
96+
try (VortexWriter writer = VortexWriter.create(session, writePath, personSchema(), options, allocator)) {
97+
assertNotNull(writer);
98+
}
99+
100+
assertTrue(Files.exists(outputPath), "output file should exist");
101+
}
102+
87103
@Test
88104
public void testWriteBatch() throws IOException {
89105
Path outputPath = tempDir.resolve("test_ffi.vortex");

vortex-jni/src/writer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ pub extern "system" fn Java_dev_vortex_jni_NativeWriter_create(
181181
let handle = session.handle().spawn(async move {
182182
match target {
183183
WriteTarget::Local(path) => {
184+
if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) {
185+
async_fs::create_dir_all(parent).await?;
186+
}
184187
let mut file = File::create(path).await?;
185188
let summary = session.write_options().write(&mut file, stream).await?;
186189
file.shutdown().await?;

0 commit comments

Comments
 (0)