|
33 | 33 | import org.apache.arrow.memory.BufferAllocator; |
34 | 34 | import org.apache.arrow.memory.RootAllocator; |
35 | 35 | import org.apache.arrow.vector.BigIntVector; |
| 36 | +import org.apache.arrow.vector.FixedSizeBinaryVector; |
36 | 37 | import org.apache.arrow.vector.IntVector; |
37 | 38 | import org.apache.arrow.vector.VarBinaryVector; |
38 | 39 | import org.apache.arrow.vector.VarCharVector; |
@@ -413,6 +414,48 @@ public void testMapRoundTrip(boolean independentBuffers) throws IOException { |
413 | 414 | } |
414 | 415 |
|
415 | 416 | /** Write a single three-row batch of {@link #personSchema()} data. */ |
| 417 | + @Test |
| 418 | + public void testUuidColumnStatisticsAreBytes() throws IOException { |
| 419 | + String writePath = |
| 420 | + tempDir.resolve("uuid_stats.vortex").toAbsolutePath().toUri().toString(); |
| 421 | + BufferAllocator allocator = ArrowAllocation.rootAllocator(); |
| 422 | + Field uuid = new Field( |
| 423 | + "id", |
| 424 | + new FieldType( |
| 425 | + false, new ArrowType.FixedSizeBinary(16), null, Map.of(ARROW_EXTENSION_NAME, "arrow.uuid")), |
| 426 | + null); |
| 427 | + Schema schema = new Schema(List.of(uuid)); |
| 428 | + byte[] low = new byte[16]; |
| 429 | + byte[] high = new byte[16]; |
| 430 | + low[15] = 1; |
| 431 | + high[0] = 0x7F; |
| 432 | + |
| 433 | + Session session = Session.create(); |
| 434 | + VortexWriteSummary summary; |
| 435 | + try (VortexWriter writer = |
| 436 | + VortexWriter.builder(session, writePath, schema, allocator).build()) { |
| 437 | + try (VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator)) { |
| 438 | + FixedSizeBinaryVector ids = (FixedSizeBinaryVector) root.getVector("id"); |
| 439 | + ids.allocateNew(2); |
| 440 | + ids.setSafe(0, high); |
| 441 | + ids.setSafe(1, low); |
| 442 | + root.setRowCount(2); |
| 443 | + |
| 444 | + try (ArrowArray array = ArrowArray.allocateNew(allocator); |
| 445 | + ArrowSchema arrowSchema = ArrowSchema.allocateNew(allocator)) { |
| 446 | + Data.exportVectorSchemaRoot(allocator, root, null, array, arrowSchema); |
| 447 | + writer.writeBatch(array.memoryAddress(), arrowSchema.memoryAddress()); |
| 448 | + } |
| 449 | + } |
| 450 | + |
| 451 | + summary = writer.finish(); |
| 452 | + } |
| 453 | + |
| 454 | + VortexColumnStatistics id = summary.columnStatistics().get(0); |
| 455 | + assertArrayEquals(low, (byte[]) id.lowerBound().orElseThrow()); |
| 456 | + assertArrayEquals(high, (byte[]) id.upperBound().orElseThrow()); |
| 457 | + } |
| 458 | + |
416 | 459 | /** |
417 | 460 | * Editions before the aggregates, such as {@code core2025.10.0}, do not permit {@code vortex.min}. The writer then |
418 | 461 | * writes only the legacy file statistics, and these must still have the min, max and null count. |
|
0 commit comments