rdblue commented on code in PR #3202:
URL: https://github.com/apache/parquet-java/pull/3202#discussion_r2069547531
##########
parquet-variant/src/test/java/org/apache/parquet/variant/TestVariantScalar.java:
##########
@@ -451,52 +630,97 @@ public void testNegativeTimestampNtz() {
(byte) 0xFF,
(byte) 0xFF
}),
- EMPTY_METADATA);
- testVariant(value, v -> {
- checkType(v, VariantUtil.PRIMITIVE, Variant.Type.TIMESTAMP_NTZ);
+ VariantTestUtil.EMPTY_METADATA);
+ VariantTestUtil.testVariant(value, v -> {
+ VariantTestUtil.checkType(v, VariantUtil.PRIMITIVE,
Variant.Type.TIMESTAMP_NTZ);
Assert.assertEquals(
Instant.parse("1969-12-31T23:59:59.999999Z"),
Instant.EPOCH.plus(v.getLong(), ChronoUnit.MICROS));
});
}
+ @Test
+ public void testTimestampNtzBuilder() {
+ DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME;
+ VariantBuilder vb = new VariantBuilder(false);
+ long micros =
VariantTestUtil.microsSinceEpoch(Instant.from(dtf.parse("2024-01-01T23:00:00.000001Z")));
+ vb.appendTimestampNtz(micros);
+ VariantTestUtil.testVariant(vb.build(), v -> {
+ VariantTestUtil.checkType(v, VariantUtil.PRIMITIVE,
Variant.Type.TIMESTAMP_NTZ);
+ Assert.assertEquals(micros, v.getLong());
+ });
+ }
+
@Test
public void testBinary() {
Variant value = new Variant(
- ByteBuffer.wrap(new byte[] {primitiveHeader(15), 0x05, 0x00, 0x00,
0x00, 'a', 'b', 'c', 'd', 'e'}),
- EMPTY_METADATA);
- testVariant(value, v -> {
- checkType(v, VariantUtil.PRIMITIVE, Variant.Type.BINARY);
+ ByteBuffer.wrap(
+ new byte[] {VariantTestUtil.primitiveHeader(15), 0x05, 0x00, 0x00,
0x00, 'a', 'b', 'c', 'd', 'e'
+ }),
+ VariantTestUtil.EMPTY_METADATA);
+ VariantTestUtil.testVariant(value, v -> {
+ VariantTestUtil.checkType(v, VariantUtil.PRIMITIVE, Variant.Type.BINARY);
Assert.assertEquals(ByteBuffer.wrap(new byte[] {'a', 'b', 'c', 'd',
'e'}), v.getBinary());
});
}
+ @Test
+ public void testBinaryBuilder() {
+ VariantBuilder vb = new VariantBuilder(false);
+ byte[] binary = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ vb.appendBinary(binary);
Review Comment:
Shouldn't this append the ByteBuffer instead? Why force the caller to copy
into a byte array starting at position 0?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]