Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-35033: [Java] [Datasets] Add support for multi-file datasets from Java#35034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d48991ef006299f2dcdf83e7195734c68a98b7ffdb920be7eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -25,7 +25,7 @@ | ||
| public class JniWrapper { | ||
| private static final JniWrapper INSTANCE = new JniWrapper(); | ||
| public static JniWrapper get() { | ||
| JniLoader.get().ensureLoaded(); | ||
| return INSTANCE; | ||
| @@ -45,6 +45,17 @@ private JniWrapper() { | ||
| */ | ||
| public native long makeFileSystemDatasetFactory(String uri, int fileFormat); | ||
| /** | ||
| * Create FileSystemDatasetFactory and return its native pointer. The pointer is pointing to a | ||
| * intermediate shared_ptr of the factory instance. | ||
| * | ||
| * @param uris List of file uris to read, each path pointing to an individual file | ||
lidavidm marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| * @param fileFormat file format ID | ||
| * @return the native pointer of the arrow::dataset::FileSystemDatasetFactory instance. | ||
| * @see FileFormat | ||
| */ | ||
| public native long makeFileSystemDatasetFactory(String[] uris, int fileFormat); | ||
| /** | ||
| * Write the content in a {@link org.apache.arrow.c.ArrowArrayStream} into files. This internally | ||
| * depends on C++ write API: FileSystemDataset::Write. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -101,6 +101,49 @@ public void testBaseParquetRead() throws Exception { | ||
| AutoCloseables.close(factory); | ||
| } | ||
| @Test | ||
| public void testMultipleParquetReadFromUris() throws Exception { | ||
| ParquetWriteSupport writeSupport1 = ParquetWriteSupport.writeTempFile(AVRO_SCHEMA_USER, TMP.newFolder(), | ||
| 1, "a"); | ||
| ParquetWriteSupport writeSupport2 = ParquetWriteSupport.writeTempFile(AVRO_SCHEMA_USER, TMP.newFolder(), | ||
| 2, "b"); | ||
| String expectedJsonUnordered = "[[1,\"a\"],[2,\"b\"]]"; | ||
| ScanOptions options = new ScanOptions(1); | ||
| FileSystemDatasetFactory factory = new FileSystemDatasetFactory(rootAllocator(), NativeMemoryPool.getDefault(), | ||
| FileFormat.PARQUET, new String[]{writeSupport1.getOutputURI(), writeSupport2.getOutputURI()}); | ||
| Schema schema = inferResultSchemaFromFactory(factory, options); | ||
| List<ArrowRecordBatch> datum = collectResultFromFactory(factory, options); | ||
| assertScanBatchesProduced(factory, options); | ||
| assertEquals(2, datum.size()); | ||
| datum.forEach(batch -> assertEquals(1, batch.getLength())); | ||
| checkParquetReadResult(schema, expectedJsonUnordered, datum); | ||
| AutoCloseables.close(datum); | ||
| AutoCloseables.close(factory); | ||
| } | ||
| @Test | ||
| public void testMultipleParquetInvalidUri() throws Exception { | ||
| RuntimeException exc = assertThrows(RuntimeException.class, | ||
| () -> new FileSystemDatasetFactory(rootAllocator(), NativeMemoryPool.getDefault(), | ||
| FileFormat.PARQUET, new String[]{"https://example.com", "file:///test/location"})); | ||
| Assertions.assertEquals("Unrecognized filesystem type in URI: https://example.com", exc.getMessage()); | ||
| } | ||
| @Test | ||
| public void testMultipleParquetMultipleFilesystemTypes() throws Exception { | ||
| RuntimeException exc = assertThrows(RuntimeException.class, | ||
| () -> new FileSystemDatasetFactory(rootAllocator(), NativeMemoryPool.getDefault(), | ||
| FileFormat.PARQUET, new String[]{"file:///test/location", "s3:///test/bucket/file" })); | ||
| Assertions.assertTrue( | ||
| exc.getMessage().startsWith("The filesystem expected a URI with one of the schemes (file) but received s3" | ||
| ) | ||
| ); | ||
| } | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be possible to add testing for exception throws: (1) Invalid URI , (2) ensure that they all share a FileSystem type | ||
| @Test | ||
| public void testParquetProjectSingleColumn() throws Exception { | ||
| ParquetWriteSupport writeSupport = ParquetWriteSupport.writeTempFile(AVRO_SCHEMA_USER, TMP.newFolder(), 1, "a"); | ||
Uh oh!
There was an error while loading. Please reload this page.