如何在 Confluent Kafka 连接中将时间戳值格式化为日期格式 - JDBC Oracle Source Connector [英] How to format Timestamp value to Date Format in Confluent Kafka connect - JDBC Oracle Source Connector

查看:39
本文介绍了如何在 Confluent Kafka 连接中将时间戳值格式化为日期格式 - JDBC Oracle Source Connector的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Kafka Connect 中设置了一个 JDBC Oracle 源连接器,我在 Oracle 表中有一个时间戳列,其值设置为日期格式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表中日期格式的列(时间戳列)的值被转换为毫秒并在主题中显示为毫秒值.我希望收到 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 连接中将时间戳值格式化为日期格式 - JDBC Oracle Source Connector的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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