Skip to content

Reading an array date value as LocalDate fails, same for other temporal types #3284

Open

Description

@anesterenok

Description

Reading an array value with conversion to another class fails, though the same conversion works for non-array values.

Steps to reproduce

  1. Create a MergeTree table with Array(Nullable(Date32)) and/or Array(Nullable(DateTime64)) and/or Array(Nullable(Time64)), add some values
  2. Query the table and read the array values as a ResultSet:
try (ResultSet trs = query.getResultSet() {
    trs.next();
    Array array = rs.getArray(columnIndex);

    ResultSet ars = array.getResultSet()) {
    while (ars.next()) {
        Object value = ars.getObject(2, LocalDate.class);  
        // or LocalDateTime.class for DateTime64, 
        // or LocalTime.class for Time64
    }
}
  1. getObject() fails

Error Log or Exception StackTrace

java.sql.SQLException: Value of class java.sql.Date cannot be converted to class java.time.LocalDate
	at com.clickhouse.jdbc.types.ArrayResultSet.convertValue(ArrayResultSet.java:146)
	at com.clickhouse.jdbc.types.ArrayResultSet.getValueAsObject(ArrayResultSet.java:168)
	at com.clickhouse.jdbc.types.ArrayResultSet.getObject(ArrayResultSet.java:1254)

Expected Behaviour

The same conversion works for row ResultSet, so I think it should work for array result sets as well.

I believe the cause is that for array conversions, com.clickhouse.client.api.data_formats.internal.ValueConverters class is used, and it does not have Date->LocalDate / Time -> LocalTime / Timestamp -> LocalDateTime conversions.

Code Example

see above

Configuration

Client Configuration

?

Environment

  • Cloud
  • Client version: JDBC driver version 0.11-all
  • Language version: JDK 17
  • OS: Ubuntu 24

ClickHouse Server

  • ClickHouse Server version: 26.10
  • ClickHouse Server non-default settings, if any: none

Activity

  1. anesterenok commented on Nov 2, 2026

    @anesterenok
    Author

    I also add that storing array time value as java.sql.Time means it gets rounded to milliseconds, while Time64 type is expected to be precise up to nanoseconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions