jeqo commented on code in PR #15379:
URL: https://github.com/apache/kafka/pull/15379#discussion_r1572436483
##########
connect/transforms/src/test/java/org/apache/kafka/connect/transforms/ValueToKeyTest.java:
##########
@@ -60,6 +62,30 @@ public void schemaless() {
assertEquals(expectedKey, transformedRecord.key());
}
+ @Test
+ public void schemalessAndNestedFields() {
+ Map<String, Object> configs = new HashMap<>();
+ configs.put("fields", "a,b.c");
+ configs.put(FieldSyntaxVersion.FIELD_SYNTAX_VERSION_CONFIG,
FieldSyntaxVersion.V2.name());
+ xform.configure(configs);
+
+ final HashMap<String, Object> value = new HashMap<>();
+ value.put("a", 1);
+ final HashMap<String, Integer> nested = new HashMap<>();
+ nested.put("c", 3);
+ value.put("b", nested);
+
+ final SinkRecord record = new SinkRecord("", 0, null, null, null,
value, 0);
+ final SinkRecord transformedRecord = xform.apply(record);
+
+ final HashMap<String, Integer> expectedKey = new HashMap<>();
+ expectedKey.put("a", 1);
+ expectedKey.put("b.c", 3);
Review Comment:
Good catch. I don't remember this scenario being discussed in the KIP
thread. Was using the original keys as they are meant to be unique, but they
could also contain all kind of escape fields making it hard to use.
Happy to switch into deriving the key schema from the nesting structure.
Will make an update to the KIP to make this explicit as well.
--
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]