简体   繁体   English

Kafka Mongo Sink 连接器,如何将 SMT 时间戳转换器用于 JSON 数组中归档的日期

[英]Kafka Mongo Sink connector , how to use SMT timestampconverter for the date filed inside a JSON array

"transforms": "TimestampConverter", “转换”:“时间戳转换器”,

"transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.TimestampConverter.format": "yyyy-MM-dd",
"transforms.TimestampConverter.target.type": "string",
"transforms.TimestampConverter.field" : "DateAtlevel2"

When this date filed is at parent level of JSON the SMT works fine, its not working when Date filed inside a JSOn array.当此日期归档在 JSON 的父级别时,SMT 工作正常,当日期归档在 JSOn 数组中时,它不起作用。

How to apply the SMT to convert a filed inside JSON array into a Date?如何应用 SMT 将 JSON 数组中的文件转换为日期?

I am using Kafka Mongo Sink connector.我正在使用 Kafka Mongo Sink 连接器。

I assume that you are using the org.apache.kafka.connect.json.JsonConverter.java which is a schemaless converter.我假设您使用的是org.apache.kafka.connect.json.JsonConverter.java这是一个无模式转换器。 In this case, you would only be able to retrieve the level 1 fields.在这种情况下,您将只能检索级别 1 字段。

Why?为什么? During the SMT phase, each record is stripped down to a plain Map<String, Object>, where String is the field name and the Object is its value.在 SMT 阶段,每条记录都被剥离为一个普通的 Map<String, Object>,其中String是字段名称, Object是它的值。 What the TimestampConverter does is to simply do a get on that map with the field name that you've passed as a config ( map.get("DateAtlevel2") ) which it can't be found. TimestampConverter 所做的只是简单地使用您作为配置传递的字段名称( map.get("DateAtlevel2") )获取 map ,但它无法找到。

To get access to level 2+ fields you would need some other type of input data that supports schemas ( AVRO, JSONSchema, or Protobuff ).要访问级别 2+ 字段,您需要一些其他类型的支持模式(AVRO、JSONSchema 或 Protobuff)的输入数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 kafka mongo sink 连接器在 mongo 中的内联 json 数组对象中附加字段值 - append field value in inline json array object in mongo through kafka mongo sink connector 使用 mongo-kafka 作为接收器连接器,如何将字段的值设置为 Date 类型? - Using mongo-kafka as sink connector, how do I set a field's value to be of Date type? 如何运行 mongo-kafka 连接器作为 kafka 的源并将其与 logstash 输入集成以使用 elasticsearch 作为接收器? - How to run the mongo-kafka connector as a source for kafka and integrate that with logstash input to use elasticsearch as a sink? 将dockerized kafka接收器连接器实现到mongo - Implement dockerized kafka sink connector to mongo kafka sink 连接器中无效 JSON 的错误处理 - Error handling for invalid JSON in kafka sink connector mongo db sink 连接器,kafka 消息密钥到 mongodb 文档字段 - mongo db sink connector, kafka message key to mongodb document field 从Kafka向MongDB传输数据时如何为非json格式的消息配置接收器连接器 - how to configure sink connector for non-json format message when streaming data from Kafka to MongDB 使用 mongo-kafka 作为接收器连接器,我如何将主题记录的值字段 map 转换为另一个值? - Using mongo-kafka as sink connector, how do I map a topic record's value field to another value? kafka mongodb接收器连接器未启动 - kafka mongodb sink connector not starting 连接Mongodb sink连接器和kafka - Connecting Mongodb sink connector and kafka
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM