|
37 | 37 | import java.util.concurrent.Executors; |
38 | 38 | import java.util.stream.Collectors; |
39 | 39 |
|
| 40 | +import org.apache.arrow.dataset.OrcWriteSupport; |
40 | 41 | import org.apache.arrow.dataset.ParquetWriteSupport; |
41 | 42 | import org.apache.arrow.dataset.jni.NativeDataset; |
42 | 43 | import org.apache.arrow.dataset.jni.NativeInstanceReleasedException; |
|
59 | 60 | import org.apache.arrow.vector.types.pojo.Schema; |
60 | 61 | import org.apache.avro.generic.GenericRecord; |
61 | 62 | import org.apache.avro.generic.GenericRecordBuilder; |
| 63 | +import org.apache.hadoop.fs.Path; |
| 64 | +import org.apache.orc.TypeDescription; |
62 | 65 | import org.junit.Assert; |
63 | 66 | import org.junit.ClassRule; |
64 | 67 | import org.junit.Test; |
@@ -357,6 +360,34 @@ public void testBaseArrowIpcRead() throws Exception { |
357 | 360 | AutoCloseables.close(factory); |
358 | 361 | } |
359 | 362 |
|
| 363 | + @Test |
| 364 | + public void testBaseOrcRead() throws Exception { |
| 365 | + String dataName = "test-orc"; |
| 366 | + String basePath = TMP.getRoot().getAbsolutePath(); |
| 367 | + |
| 368 | + TypeDescription orcSchema = TypeDescription.fromString("struct<ints:int>"); |
| 369 | + Path path = new Path(basePath, dataName); |
| 370 | + OrcWriteSupport.writeTempFile(orcSchema, path, new Integer[]{Integer.MIN_VALUE, Integer.MAX_VALUE}); |
| 371 | + |
| 372 | + String orcDatasetUri = new File(basePath, dataName).toURI().toString(); |
| 373 | + FileSystemDatasetFactory factory = new FileSystemDatasetFactory(rootAllocator(), NativeMemoryPool.getDefault(), |
| 374 | + FileFormat.ORC, orcDatasetUri); |
| 375 | + ScanOptions options = new ScanOptions(100); |
| 376 | + Schema schema = inferResultSchemaFromFactory(factory, options); |
| 377 | + List<ArrowRecordBatch> datum = collectResultFromFactory(factory, options); |
| 378 | + |
| 379 | + assertSingleTaskProduced(factory, options); |
| 380 | + assertEquals(1, datum.size()); |
| 381 | + assertEquals(1, schema.getFields().size()); |
| 382 | + assertEquals("ints", schema.getFields().get(0).getName()); |
| 383 | + |
| 384 | + String expectedJsonUnordered = "[[2147483647], [-2147483648]]"; |
| 385 | + checkParquetReadResult(schema, expectedJsonUnordered, datum); |
| 386 | + |
| 387 | + AutoCloseables.close(datum); |
| 388 | + AutoCloseables.close(factory); |
| 389 | + } |
| 390 | + |
360 | 391 | private void checkParquetReadResult(Schema schema, String expectedJson, List<ArrowRecordBatch> actual) |
361 | 392 | throws IOException { |
362 | 393 | final ObjectMapper json = new ObjectMapper(); |
|
0 commit comments