wombatu-kun commented on code in PR #16604:
URL: https://github.com/apache/iceberg/pull/16604#discussion_r3994494243
##########
kafka-connect/kafka-connect-transforms/src/test/java/org/debezium/connector/mongodb/transforms/TestMongoArrayConverter.java:
##########
@@ -389,4 +395,60 @@ public void
shouldCreateStructForHeterogenousDocumentInArray() throws Exception
"Struct{" + "_id=1," + "a1=Struct{" + "_0=Struct{a=1}," +
"_1=Struct{a=c}" + "}" + "}");
// @formatter:on
}
+
+ @Test
+ @SuppressWarnings("JavaUtilDate")
+ public void shouldConvertArrayOfTimestamps() {
+ final MongoDataConverter converter = new
MongoDataConverter(ArrayEncoding.ARRAY);
+ final BsonDocument val =
+ new BsonDocument()
+ .append("_id", new BsonInt32(1))
+ .append(
+ "ts",
+ new BsonArray(Arrays.asList(new BsonTimestamp(60, 1), new
BsonTimestamp(120, 1))));
+
+ final SchemaBuilder schemaBuilder = SchemaBuilder.struct().name("array");
+ for (Entry<String, BsonValue> entry : val.entrySet()) {
+ converter.addFieldSchema(entry, schemaBuilder);
+ }
+ final Schema finalSchema = schemaBuilder.build();
+ final Struct struct = new Struct(finalSchema);
+ for (Entry<String, BsonValue> entry : val.entrySet()) {
+ converter.convertRecord(entry, finalSchema, struct);
+ }
+
+ // BsonTimestamp.getTime() returns the seconds component; the scalar path
multiplies by 1000
+ List<?> tsValues = (List<?>) struct.get("ts");
+ assertThat(tsValues).hasSize(2);
+ assertThat(tsValues.get(0)).isEqualTo(new Date(60_000L));
+ assertThat(tsValues.get(1)).isEqualTo(new Date(120_000L));
+ }
+
+ @Test
+ @SuppressWarnings("JavaUtilDate")
+ public void shouldConvertArrayOfDateTimes() {
Review Comment:
Done d205dfa0e5d1, for `TIMESTAMP` only. The DOCUMENT `DATE_TIME` branch is
already pinned by
`TestMongoDataConverter.shouldCreateCorrectStructFromInsertJson`, where the
`grades[].date` fields route through the same scalar overload, whereas scalar
`TIMESTAMP` had no coverage anywhere in the repo.
--
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]