raminqaf commented on code in PR #28928:
URL: https://github.com/apache/flink/pull/28928#discussion_r3726321755
##########
flink-core/src/test/java/org/apache/flink/types/variant/BinaryVariantTest.java:
##########
@@ -334,4 +289,30 @@ void testGetThrowException() {
.isInstanceOf(VariantTypeException.class)
.hasMessage("Expected type DOUBLE but got FLOAT");
}
+
+ @Test
+ void testJavaSerialization() throws Exception {
+ Variant variant =
+ builder.object()
+ .add("i", builder.of(1))
+ .add("nested",
builder.array().add(builder.of("v")).build())
+ .build();
+ assertThat(javaRoundTrip(variant)).isEqualTo(variant);
+
+ // a sub-variant is addressed by a position into the value binary of
the enclosing document
+ Variant subVariant = variant.getField("nested");
+ assertThat(((BinaryVariant) subVariant).getPos()).isGreaterThan(0);
+ assertThat(javaRoundTrip(subVariant)).isEqualTo(subVariant);
+ }
+
+ private static Variant javaRoundTrip(Variant variant) throws Exception {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Review Comment:
Removed the helper and replaced it with
`CommonTestUtils.createCopySerializabl`
##########
flink-core/src/test/java/org/apache/flink/types/variant/BinaryVariantTest.java:
##########
@@ -334,4 +289,30 @@ void testGetThrowException() {
.isInstanceOf(VariantTypeException.class)
.hasMessage("Expected type DOUBLE but got FLOAT");
}
+
+ @Test
+ void testJavaSerialization() throws Exception {
+ Variant variant =
+ builder.object()
+ .add("i", builder.of(1))
+ .add("nested",
builder.array().add(builder.of("v")).build())
+ .build();
+ assertThat(javaRoundTrip(variant)).isEqualTo(variant);
+
+ // a sub-variant is addressed by a position into the value binary of
the enclosing document
+ Variant subVariant = variant.getField("nested");
+ assertThat(((BinaryVariant) subVariant).getPos()).isGreaterThan(0);
+ assertThat(javaRoundTrip(subVariant)).isEqualTo(subVariant);
+ }
+
+ private static Variant javaRoundTrip(Variant variant) throws Exception {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Review Comment:
Removed the helper and replaced it with
`CommonTestUtils.createCopySerializable`
--
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]