confluentinc / kafka-connect-jdbc

Kafka Connect connector for JDBC-compatible databases
Other
1.01k stars 953 forks source link

[CC-24785] Fixed handling of Date column type in Sink connectors when db.timezone is set #1398

Closed Tanish0019 closed 3 months ago

Tanish0019 commented 4 months ago

Problem

CC-24785 The Java.Sql.Date datatype only contains the day, month and year information and does not have the time. In the Kafka record it is stored as an integer which signifies the number of days since epoch date. When we bind it to the preparedStatement to build the insert query, we're using the db.timezone config on it to update it. Anything that is before the UTC will subtract the date by 1 because while applying the timezone it is assumed that the value of time is 00:00:00Z.

Solution

Added a config date.timezone to control what timezone to be used for converting the Date. The config is added to maintain backward compatibility. The default behaviour of the connector will remain the same and setting the config to UTC will make the Date pass as is without any conversion.

Does this solution apply anywhere else?
If yes, where?

Test Strategy

Testing done:

Release Plan

[CC-24785]: https://confluentinc.atlassian.net/browse/CC-24785?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
sonarqube-confluent[bot] commented 4 months ago

Passed

Analysis Details

0 Issues

Coverage and Duplications

Project ID: kafka-connect-jdbc

View in SonarQube

ConfluentJenkins commented 4 months ago

passed

Analysis Details

0 Issues

Project ID: kafka-connect-jdbc View in SonarQube

sonarqube-confluent[bot] commented 4 months ago

Passed

Analysis Details

0 Issues

Coverage and Duplications

Project ID: kafka-connect-jdbc

View in SonarQube