Kafka Connect 墓碑消息不应用 InsertField 转换

Kafka Connect tombstone message doesn't apply InsertField transformation

插入字段转换未应用于逻辑删除消息。

我使用的是 postgres 10.1 / debezium 1.2.1 版本 / kafka 2.4.1 版本

例如。

{
...
    "transforms": "InsertField",
    "transforms.InsertField.type": "org.apache.kafka.connect.transforms.InsertField$Key",
    "transforms.InsertField.static.field": "__host",
    "transforms.InsertField.static.value": "abc.com",
...
}
key - {"id":1, "__host": "abc.com"}, value - {"id":1, "__host": "abc.com", "col1": 1, "col2": "a"}
key - {"id":1, "__host": "abc.com"} value - {"id":1, "__host": "abc.com", "col1": null, "col2": null}
key - {"id":1} value - null

为什么会这样?是错误吗?还是我错了?

逻辑删除消息的 InsertField 转换的预期行为:

The key field is inserted, and the value remains null.

但是在你的Kafka Connect版本(2.4.1)中有一个bug:key字段没有插入。 它已在 KAFKA-9707: InsertField.Key transformation should apply to tombstone records

中修复

您可以将 Kafka Connect 集群升级到某个修复版本(例如 2.4.2)。