如何使用 SMT 转换不同主题的重命名字段 [英] How to transform rename fields for different topics using SMT

查看:36
本文介绍了如何使用 SMT 转换不同主题的重命名字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个主题需要重命名它显示的架构状态中的字段 Caused by: org.apache.kafka.connect.errors.ConnectException: Table: topic2 is missing field ([SinkRecordField{schema=Schema{STRING}, name='stand_user', isPrimaryKey=false}]

I have multiple topics that needs to rename the fields in the schema status it shows Caused by: org.apache.kafka.connect.errors.ConnectException: Table: topic2 is missing field ([SinkRecordField{schema=Schema{STRING}, name='stand_user', isPrimaryKey=false}]

所以我的配置是这样的

"topics":"topic1, topic2",
"transforms":"RenameField",
"transforms.RenameField.type":"org.apache.kafka.connect.transforms.ReplaceField$Value",
"transforms.RenameField.renames":"user:stand_user, user:session_user",

stand_user 是 topic1 的一部分,而 session_user 是 topic2 的一部分现在 topic2 出错了,因为即使 stand_user 应该只在 topic1 中,它也不能很好 stand_user.我试着把它分开

Where the stand_user is part of topic1 but session_user is part of topic2 Right now topic2 is erroring because it can't fine stand_user even though stand_user should only be in topic1. I tried to separate it as

"topics":"topic1, topic2",
"transforms":"RenameTopic1Field, RenameTopic2Field",
"transforms.RenameTopic1Field.type":"org.apache.kafka.connect.transforms.ReplaceField$Value",
"transforms.RenameTopic1Field.renames":"user:stand_user",
"transforms.RenameTopic2Field.type":"org.apache.kafka.connect.transforms.ReplaceField$Value",
"transforms.RenameTopic2Field.renames":"user:session_user",

但是重命名中的下一个字段失败了同样的错误任何将主题重命名分开的建议

But then the next field in the rename failed same error Any suggestion to separate the topic rename

推荐答案

转换适用于配置中的所有主题

Transforms apply to all topics in the config

如果您无法将特定转换应用于该连接器使用的单个主题,它将阻止连接器读取所有其他主题,因此您必须创建单独的配置以隔离所需的行为

If you can't apply a particular transform to a single topic consumed by that connector, it'll halt the connector from reading all other topics, so you must create a separate config to isolate the desired behavior

这篇关于如何使用 SMT 转换不同主题的重命名字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆