apache / apache/arrow-java

[C++][Java] When i use DatasetFileWriter::write method write a file, I can't specify a file name

Open
#64 4 comments 0 reactions 0 assignees View on GitHub
Type: usage
Dominant language
Java
Stars
94
Forks
152
Avg merge
3d 16h
Merged PRs (30d)
11

Description

### Describe the usage question you have. Please include as many useful details as possible.

I use this static method to write a parquet file into fs, I give empty partition array, so it will be in a file; and i give the `baseNameTemplate` arg is "test.parquet" to specify the filename, but it leads to an error: `basename_template did not contain '{i}'`.
```java
public static void write(BufferAllocator allocator, ArrowReader reader, FileFormat format, String uri,
String[] partitionColumns, int maxPartitions, String baseNameTemplate) {
try (final ArrowArrayStream stream = ArrowArrayStream.allocateNew(allocator)) {
Data.exportArrayStream(allocator, reader, stream);
JniWrapper.get().writeFromScannerToFile(stream.memoryAddress(),
format.id(), uri, partitionColumns, maxPartitions, baseNameTemplate);
}
}
```
read the cpp jni code and cpp dataset's code, the FileSystemDatasetWriteOptions::basename_template seems not supported to specify the file name without `{i}`.
```cpp
/// \brief Options for writing a dataset.
struct ARROW_DS_EXPORT FileSystemDatasetWriteOptions {
.
.
.
/// Template string used to generate fragment basenames.
/// {i} will be replaced by an auto incremented integer.
std::string basename_template;
.
.
.
}
```
If there is any method to specify the filename when none partition?

### Component(s)

Java

Contributor guide

Open the contributing guide

Research direction

Start with Java DatasetFileWriter::write and the JNI call to writeFromScannerToFile, then inspect C++ FileSystemDatasetWriteOptions::basename_template. Determine whether a non-partitioned write can accept an exact filename without {i}; done means the supported behavior is established and the Java/C++ path handles or clearly documents that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, java
Domain
data-engineering
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.