Apache kafka 使用Kafka Connect时如何转换所有时间戳字段?

Apache kafka 使用Kafka Connect时如何转换所有时间戳字段?,apache-kafka,apache-kafka-connect,Apache Kafka,Apache Kafka Connect,我正在尝试将所有时间戳字段转换为格式为yyyy-MM-dd HH:MM:ss的字符串类型 要转换多个字段,我必须分别为每个字段创建一个转换 ... "transforms":"tsFormat1,tsFormat2,...,tsFormatN", "transforms.tsFormat1.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value", "transforms.tsFormat1.target.type

我正在尝试将所有时间戳字段转换为格式为
yyyy-MM-dd HH:MM:ss
的字符串类型

要转换多个字段,我必须分别为每个字段创建一个转换

...
"transforms":"tsFormat1,tsFormat2,...,tsFormatN",
"transforms.tsFormat1.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat1.target.type": "string",
"transforms.tsFormat1.field": "ts_col1",
"transforms.tsFormat1.format": "yyyy-MM-dd HH:mm:ss",
"transforms.tsFormat2.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat2.target.type": "string",
"transforms.tsFormat2.field": "ts_col2",
"transforms.tsFormat2.format": "yyyy-MM-dd HH:mm:ss",
...
"transforms.tsFormatN.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormatN.target.type": "string",
"transforms.tsFormatN.field": "ts_colN",
"transforms.tsFormatN.format": "yyyy-MM-dd HH:mm:ss",
...

有没有办法对所有时间戳列应用单个转换

我试过了

...
"transforms":"tsFormat",
"transforms.tsFormat.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat.target.type": "string",
"transforms.tsFormat.field": "ts_col1, ts_col2,..., ts_colN",
"transforms.tsFormat.format": "yyyy-MM-dd HH:mm:ss",
...



更好的是数字类型匹配
“numeric.mapping”:“best_fit”
。就像
numeric.mapping
如何应用于所有数字字段(无需手动指定字段名称)以尝试找到最佳的数字类型一样,是否有类似的东西可以对所有时间戳字段应用转换或字符串格式?

。字段
是单数
numeric.mapping
不是Connect API的一部分,那么您使用的是哪个连接器?我知道
.field
是单数的。这就是为什么我要问是否有其他方法来实现这一点。我使用的是
io.confluent.connect.jdbc.JdbcSourceConnector
连接器。除了为每个时间戳列单独创建一个转换外,是否有其他方法格式化所有时间戳列?没有。。。选项1)最初使用正确的时间戳写入数据。选项2)在Connect的使用者之前使用Kafka Streams或KSQL。选项3)让数据按原样进入数据库,然后在以后实际在应用程序中显示数据时使用数据库函数对其进行解析
...
"transforms":"tsFormat",
"transforms.tsFormat.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat.target.type": "string",
"transforms.tsFormat.field": "ts_col1",
"transforms.tsFormat.field": "ts_col2",
...
"transforms.tsFormat.field": "ts_colN",
"transforms.tsFormat.format": "yyyy-MM-dd HH:mm:ss",
...