Skip to content

[JDBC, Client] DateTime logic should be in the client #2416

@chernser

Description

@chernser

Description

Date/Time data types are most complex in terms of working with them. First - there are different classes in Java that handles time. Second - conversion between them may lead to errors in data because of many parameters should be cared about. Maintaining good support for these types requires code to be well tested and coherent. We need to move all related code to the client.

Data Type Match to Java Class

ClickHouse Type Java Class
Date ZonedDateTime
Date32 ZonedDateTime
DateTime ZonedDateTime
DateTime64 ZonedDateTime
Time Integer
Time64 Long

Most of date/time types are represented with ZonedDateTime to carry timezone information.
Time and Time64 are represented as Integer/Long because they have no timezone information.

JDBC Use Cases

There are several usecases in the JDBC driver that require ClickHouse data type conversion to one of Java Date/Time classes.

PreparedStatement interface has methods that require the conversion:

  • setTime(Time, Calendar)
  • setTimestamp(Timestamp, Calendar)
  • setDate(Date, Calendar)
  • setObject(Object, SQLType) - there are can be anything Instant, LocalTime event a string?.

ResultSet interface has next methods that require the conversion:

  • getDate(int columnIndex, Calendar cal)
  • getTime(int columnIndex, Calendar cal)
  • getTimestamp(int columnIndex, Calendar cal)

Other Use Cases

  • Formatting Java Date/Time classes into a string suitable for DB

Sub-issues

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions