jdbc oracle源连接器中将时间戳值格式化为日期格式

hl0ma9xz  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(494)

我在kafka connect中设置了一个jdbc-oracle源连接器,在oracle表中有一个timestamp列,其值设置为日期格式“21-mar-18 05.39.44.0194990 am”。
oracle表中的所有数据都被提取到kafka主题中,但是oracle表中date格式的列(timestamp列)的值被转换为毫秒,并在主题中显示为毫秒值。我想收到的日期格式,因为它是在甲骨文表。

{
  "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"
  }
}

db表列:

UPDATED_ON  TIMESTAMP(6)    Not Null
column value - 27-MAR-18 05.39.44.0194490 AM

价值topic:1522129184019 (等效毫秒格式)

rekjcdws

rekjcdws1#

您可以使用smt时间转换器
https://docs.confluent.io/current/connect/transforms/timestampconverter.html#timestampconverter
解决问题的示例seam:

"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"

相关问题