Kafka Connect JDBC db.timezone 配置

Kafka Connect JDBC db.timezone config

我正在努力思考 db.timezone 属性 如何在源连接器和接收器连接器上工作。

对于源代码,文档说:

Name of the JDBC timezone used in the connector when querying with time-based criteria. Defaults to UTC.

这到底是什么意思?那应该设置为我的源数据库的时区吗?我有一个设置为东部时区的数据库。我需要将其设置为 US/Eastern 吗?如果我不这样做会怎样?

在接收器方面,文档说:

Name of the JDBC timezone that should be used in the connector when inserting time-based values. Defaults to UTC.

再说一遍这到底是什么意思。它是否使用它来将有效负载中的所有时间戳转换为您在此处提供的值?

我的具体问题是我的源数据库有东部时区,但我的接收器数据库设置为 UTC,我无法更改它。我应该如何定义这些属性。

此外,我认为这有点不相关,但我注意到在我的接收器端时间戳没有所有小数。但是在双方都有时间戳列设置为时间戳(6)。但是在sink端,小数点总是只有3位,其余3位全为0。为什么会这样?

查看源代码:

https://github.com/confluentinc/kafka-connect-jdbc/blob/master/src/main/java/io/confluent/connect/jdbc/source/JdbcSourceConnectorConfig.java#L805

了解您为 db.timezone 配置选项指定的值将如何被 kafka-connect-jdbc 连接器使用。

我假设您的源连接器应该使用

db.timezone=US/Eastern

Name of the JDBC timezone used in the connector when querying with time-based > criteria. Defaults to UTC. What does this actually mean?

当 reading/writing 数据库中的数据不使用 UTC 时区存储 date/time 列时,db.timezone 设置会派上用场。

由于您的接收器数据库使用 UTC 时区,因此在您的 jdbc 接收器配置中没有与设置时区相关的其他设置。