vroyer commented on a change in pull request #13866:
URL: https://github.com/apache/pulsar/pull/13866#discussion_r797655424
##########
File path:
pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/JsonConverterTests.java
##########
@@ -109,43 +124,47 @@ public void testLogicalTypesToJson() throws IOException {
.name("timemillis").type(timeMillisType).noDefault()
.name("timemicros").type(timeMicrosType).noDefault()
.name("myuuid").type(uuidType).noDefault()
+ .name("myCQLVarint").type(cqlVarintType).noDefault()
+ .name("myduration").type(durationType).noDefault()
+ .name("myCQLDecimal").type(cqlDecimalType).noDefault()
+
.endRecord();
final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
BigDecimal myDecimal = new BigDecimal("100.003");
UUID myUuid = UUID.randomUUID();
Calendar calendar = new
GregorianCalendar(TimeZone.getTimeZone("Europe/Copenhagen"));
+ GenericRecord myCQLDecimal = new GenericData.Record(cqlDecimalType);
+ myCQLDecimal.put("bigint", BigInteger.valueOf(123).toByteArray());
+ myCQLDecimal.put("scale", 2);
+
+ GenericRecord myduration = new GenericData.Record(durationType);
+ myduration.put("months", 5);
+ myduration.put("days", 2);
+ myduration.put("nanoseconds", 1000 * 1000 * 1000 * 30L); // 30 seconds
+
GenericRecord genericRecord = new GenericData.Record(schema);
genericRecord.put("mydate",
(int)calendar.toInstant().getEpochSecond());
genericRecord.put("tsmillis", calendar.getTimeInMillis());
genericRecord.put("tsmicros", calendar.getTimeInMillis() * 1000);
genericRecord.put("timemillis", (int)(calendar.getTimeInMillis() %
MILLIS_PER_DAY));
genericRecord.put("timemicros", (calendar.getTimeInMillis()
%MILLIS_PER_DAY) * 1000);
genericRecord.put("myuuid", myUuid.toString());
+ genericRecord.put("myCQLVarint",
BigInteger.valueOf(12234).toByteArray());
+ genericRecord.put("myCQLDecimal", myCQLDecimal);
+ genericRecord.put("myduration", myduration);
- GenericRecord genericRecord2 = deserialize(serialize(genericRecord,
schema), schema);
- JsonNode jsonNode = JsonConverter.toJson(genericRecord2);
Review comment:
This was introduces in a this
[fix](https://github.com/apache/pulsar/pull/13652) to check there was no issue
with serialisation/deserialisation with the UUID logical type. I think we
should keep it.
##########
File path:
pulsar-io/elastic-search/src/test/java/org/apache/pulsar/io/elasticsearch/JsonConverterTests.java
##########
@@ -109,43 +124,47 @@ public void testLogicalTypesToJson() throws IOException {
.name("timemillis").type(timeMillisType).noDefault()
.name("timemicros").type(timeMicrosType).noDefault()
.name("myuuid").type(uuidType).noDefault()
+ .name("myCQLVarint").type(cqlVarintType).noDefault()
+ .name("myduration").type(durationType).noDefault()
+ .name("myCQLDecimal").type(cqlDecimalType).noDefault()
+
.endRecord();
final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
BigDecimal myDecimal = new BigDecimal("100.003");
UUID myUuid = UUID.randomUUID();
Calendar calendar = new
GregorianCalendar(TimeZone.getTimeZone("Europe/Copenhagen"));
+ GenericRecord myCQLDecimal = new GenericData.Record(cqlDecimalType);
+ myCQLDecimal.put("bigint", BigInteger.valueOf(123).toByteArray());
+ myCQLDecimal.put("scale", 2);
+
+ GenericRecord myduration = new GenericData.Record(durationType);
+ myduration.put("months", 5);
+ myduration.put("days", 2);
+ myduration.put("nanoseconds", 1000 * 1000 * 1000 * 30L); // 30 seconds
+
GenericRecord genericRecord = new GenericData.Record(schema);
genericRecord.put("mydate",
(int)calendar.toInstant().getEpochSecond());
genericRecord.put("tsmillis", calendar.getTimeInMillis());
genericRecord.put("tsmicros", calendar.getTimeInMillis() * 1000);
genericRecord.put("timemillis", (int)(calendar.getTimeInMillis() %
MILLIS_PER_DAY));
genericRecord.put("timemicros", (calendar.getTimeInMillis()
%MILLIS_PER_DAY) * 1000);
genericRecord.put("myuuid", myUuid.toString());
+ genericRecord.put("myCQLVarint",
BigInteger.valueOf(12234).toByteArray());
+ genericRecord.put("myCQLDecimal", myCQLDecimal);
+ genericRecord.put("myduration", myduration);
- GenericRecord genericRecord2 = deserialize(serialize(genericRecord,
schema), schema);
- JsonNode jsonNode = JsonConverter.toJson(genericRecord2);
Review comment:
This was introduces in this
[fix](https://github.com/apache/pulsar/pull/13652) to check there was no issue
with serialisation/deserialisation with the UUID logical type. I think we
should keep it.
--
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]