-
Bug
-
Resolution: Done
-
Major
-
1.8.0.Final
-
None
-
False
-
False
-
-
When using the outbox transformer with`transforms.outbox.table.expand.json.payload` set to `true` it fails to expand the JSON content in case of nested arrays of objects due to the following exception:
org.apache.kafka.connect.errors.SchemaBuilderException: Cannot create field because of field name duplication @type2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at org.apache.kafka.connect.data.SchemaBuilder.field(SchemaBuilder.java:330) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.addFieldSchema(SchemaBuilderUtil.java:53) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.buildDocumentUnionSchema(SchemaBuilderUtil.java:146) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.findArrayMemberSchema(SchemaBuilderUtil.java:117) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonValueToSchema(SchemaBuilderUtil.java:78) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.addFieldSchema(SchemaBuilderUtil.java:51) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonNodeToSchemaBuilder(SchemaBuilderUtil.java:42) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonNodeToSchema(SchemaBuilderUtil.java:33) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonValueToSchema(SchemaBuilderUtil.java:80) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.addFieldSchema(SchemaBuilderUtil.java:51) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonNodeToSchemaBuilder(SchemaBuilderUtil.java:42) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.SchemaBuilderUtil.jsonNodeToSchema(SchemaBuilderUtil.java:33) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.EventRouterDelegate.apply(EventRouterDelegate.java:162) 2022-02-04T19:41:15.000Z [Worker-0d64059776637fd2c] at io.debezium.transforms.outbox.EventRouter.apply(EventRouter.java:25)
It seems that the problem is caused by the fact that the code iterates over all elements of the array and it always tries to add their fields to the schema - which is fine in case of simple types, but not in the case of objects