Kafka SMT用于ISO UTC日期时间格式的日期时间转换 [英] Kafka SMT for datetime conversion in ISO UTC datetime format

查看:142
本文介绍了Kafka SMT用于ISO UTC日期时间格式的日期时间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将MySQL中类型为 datetime 的列转换为源连接器中的UTC-ISO DateTime格式?

Is it possible to convert a column of type datetime in MySQL be converted to UTC-ISO DateTime format in the source connector?

输入详细信息
列名称:Modified_dtmStamp
样本值:2018-08-03 16:37:20

Input Details
Column Name: Modified_dtmStamp
Sample Value: 2018-08-03 16:37:20

... 
"transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
        "transforms.TimestampConverter.field": "Modified_dtmStamp",
        "transforms.TimestampConverter.format": "ISO_INSTANT",
        "transforms.TimestampConverter.target.type": "Timestamp"

以上述代码段的形式引用 https://docs.confluent.io/current/connect/transforms/timestampconverter.html .

Implemented the above snippet referring to https://docs.confluent.io/current/connect/transforms/timestampconverter.html.

错误:


"trace": "org.apache.kafka.common.config.ConfigException: Invalid value java.lang.IllegalArgumentException: Illegal pattern character 'I' for configuration TimestampConverter requires a SimpleDateFormat-compatible pattern for string timestamps: ISO_INSTANT\n\tat org.apache.kafka.connect.transforms.TimestampConverter.configure(TimestampConverter.java:263)\n\tat org.apache.kafka.connect.runtime.ConnectorConfig.transformations(ConnectorConfig.java:257)\n\tat ........
------------------------------------------------------------------------

在上述连接器代码段中,将 format 更改为 yyyy-MM-dd 即可,如示例所示.

Changing the format to yyyy-MM-dd in the above connector snippet works as given in the examples.

但是,专门寻找UTC-ISO格式.ISO_INSTANT可以解决问题,但在这种情况下不起作用.

However, looking for UTC-ISO format specifically. ISO_INSTANT does the trick, but not working in this case.

推荐答案

ISO_INSTANT 不是SimpleDateFormat字符串格式,而是 java.time.* 中的静态字段.API,Connect不使用

ISO_INSTANT isn't a SimpleDateFormat string format, it's a static field within java.time.* API, which Connect doesn't use

您必须明确写出"yyyy-MM-dd HH:mm:ss"的完整值

You'd have to explicitly write out the full value for "yyyy-MM-dd HH:mm:ss"

这篇关于Kafka SMT用于ISO UTC日期时间格式的日期时间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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