如何在Confluent Kafka Connect中将Timestamp值格式化为Date格式-JDBC Oracle Source Connector [英] How to format Timestamp value to Date Format in Confluent Kafka connect - JDBC Oracle Source Connector
问题描述
我已经在Kafka Connect中设置了JDBC Oracle Source Connector,并且在Oracle表中有一个timestamp列,其值设置为日期格式"21-MAR-18 05.39.44.0194990 AM".
I have setup a JDBC Oracle Source Connector in Kafka Connect and I have a timestamp column in Oracle table whose value is set as date format "21-MAR-18 05.39.44.0194990 AM".
Oracle表中的所有数据都被提取到Kafka主题中,但是oracle表中具有日期格式的列(timestamp列)的值被转换为毫秒,并在主题中显示为毫秒值.我想收到Oracle表中的日期格式.
All the data from the Oracle table is fetched into the Kafka topics, but the value of column with date format (timestamp column) in oracle table is converted to milliseconds and displayed in the topic as milliseconds value. I would like to have the date format received as it is in Oracle table.
{
"name":"JDBC_CONN_1",
"config": {
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"connection.url": "jdbc:oracle:thin:@<hostname>:1521/<servicename>",
"connection.user": "User",
"connection.password": "Password",
"table.whitelist": "Table_Name",
"catalog.pattern": "",
"schema.pattern": "Schema_Name",
"mode": "bulk",
"poll.interval.ms": "1000",
"numeric.mapping":"best_fit",
"topic.prefix": "JDBC_CONN_1"
}
}
数据库表列:
UPDATED_ON TIMESTAMP(6) Not Null
column value - 27-MAR-18 05.39.44.0194490 AM
主题中的值:1522129184019(等效毫秒格式)
Value in Topic:1522129184019 (equivalent milli second format)
推荐答案
您可以使用SMT TimeStampConverter
You can use the SMT TimeStampConverter
https://docs.confluent.io/current/connect/transforms/timestampconverter.html#timestampconverter
用于解决您问题的示例缝线:
The exemple seam to resolve your problem :
"transforms": "TimestampConverter",
"transforms.TimestampConverter.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.TimestampConverter.format": "yyyy-MM-dd"
"transforms.TimestampConverter.target.type": "string"
之前: 1556204536000
之后:"2014-04-25"
这篇关于如何在Confluent Kafka Connect中将Timestamp值格式化为Date格式-JDBC Oracle Source Connector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!