You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reading an array date value as LocalDate fails, same for other temporal types #3284
Reading an array value with conversion to another class fails, though the same conversion works for non-array values.
Steps to reproduce
Create a MergeTree table with Array(Nullable(Date32)) and/or Array(Nullable(DateTime64)) and/or Array(Nullable(Time64)), add some values
Query the table and read the array values as a ResultSet:
try (ResultSettrs = query.getResultSet() {
trs.next();
Arrayarray = rs.getArray(columnIndex);
ResultSetars = array.getResultSet()) {
while (ars.next()) {
Objectvalue = ars.getObject(2, LocalDate.class);
// or LocalDateTime.class for DateTime64, // or LocalTime.class for Time64
}
}
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
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.
Just conversion is not a solution for this problem because converting Date to LocalDate should be done with care to timezone. LocalDate is date in some local timezone and DB value has none.
Date values are already read as LocalDate internally and conversion to Date then to LocalDate back might be not correct.
Issue is in Array object as I see it is created as array of Date objects.
I don't quite get it.
LocalDate (or Date, for that matter) is not influenced by TZ at all, as well as LocalTime.
Even for LocalDateTime, its "naive" datetime which is not in any local time zone, its just bunch of numbers.
And you already support that conversion for primitive fields, just as the JDBC spec tolds to.
I don't really see how conversion of array elements is supposed to be different from converting primitive values. Yes, I understand that on physical level these are represented differently, but we're talking API, right?
And from API viewpoint, it should not matter whether I read a "real" ResultSet, or an Array one. In fact, that's the whole point of JDBC specifying reading arrays as result sets in the first place.
Recommendation: Keep open — fix needed
Open PR #3311 does not fix the issue's steps: with its diff, the three getObject calls still fail. It changes only the BinaryStreamReader.ArrayValue path, but jdbc-v2 reads an array as a List by default. It does not cover the Time64 fraction loss either; if #3311 closes this issue, that part needs its own issue.
Category: Bug
Classification: impact: Data integrity · area: Data types & formats (Array(Date32), Array(DateTime64), Array(Time64))
Status on main: Reproduced on main — the three calls fail with the reported error; a Time64 element loses its whole fraction, with no error.
Breaking change: No — can be done without a break, if the array elements keep their current Java classes.
Duplicates / related: None found
Analysis:ArrayResultSet.java:157 throws because ValueConverters gives java.sql.Date, Time, and Timestamp only an identity and a String conversion (ValueConverters.java:110-115). The elements have these classes because jdbc-v2 reads an array as a List by default (JdbcConfiguration.java:568) and converts each element in JdbcUtils.convert (JdbcUtils.java:331, :420-426). The second defect in the comments: JdbcUtils.java:426 makes a Time64 element with Time.valueOf(LocalTime), which drops the whole fraction, not only the part below milliseconds (12:34:56.123456789 becomes 12:34:56.000).
Reproduction: complete program and output
Changed from the issue's steps: one table with the three types, a Date32 row column as a contrast, and a Time64(9) element read with getArray().
d array getObject(2, LocalDate): java.sql.SQLException: Value of class java.sql.Date cannot be converted to class java.time.LocalDate
dt array getObject(2, LocalDateTime): java.sql.SQLException: Value of class java.sql.Timestamp cannot be converted to class java.time.LocalDateTime
t array getObject(2, LocalTime): java.sql.SQLException: Value of class java.sql.Time cannot be converted to class java.time.LocalTime
t array element: java.sql.Time 12:34:56, getTime()=45296000
row d1 getObject(4, LocalDate): 2024-01-02
build=0
d array getObject(2, LocalDate): java.sql.SQLException: Value of class java.sql.Date cannot be converted to class java.time.LocalDate
dt array getObject(2, LocalDateTime): java.sql.SQLException: Value of class java.sql.Timestamp cannot be converted to class java.time.LocalDateTime
t array getObject(2, LocalTime): java.sql.SQLException: Value of class java.sql.Time cannot be converted to class java.time.LocalTime
t array element: java.sql.Time 12:34:56, getTime()=45296000
row d1 getObject(4, LocalDate): 2024-01-02
Automated triage by Polyglot AI. A maintainer makes the final decision.
Activity
anesterenok commentedon Nov 2, 2026
I also add that storing array time value as
java.sql.Timemeans it gets rounded to milliseconds, whileTime64type is expected to be precise up to nanoseconds.chernser commentedon Nov 17, 2026
@anesterenok Thank you for reporting this!
Just conversion is not a solution for this problem because converting Date to LocalDate should be done with care to timezone. LocalDate is date in some local timezone and DB value has none.
Date values are already read as
LocalDateinternally and conversion toDatethen toLocalDateback might be not correct.Issue is in Array object as I see it is created as array of
Dateobjects.lets review together and decide.
CC: @pcbeingused333
anesterenok commentedon Nov 19, 2026
I don't quite get it.
LocalDate (or Date, for that matter) is not influenced by TZ at all, as well as LocalTime.
Even for LocalDateTime, its "naive" datetime which is not in any local time zone, its just bunch of numbers.
And you already support that conversion for primitive fields, just as the JDBC spec tolds to.
I don't really see how conversion of array elements is supposed to be different from converting primitive values. Yes, I understand that on physical level these are represented differently, but we're talking API, right?
And from API viewpoint, it should not matter whether I read a "real" ResultSet, or an Array one. In fact, that's the whole point of JDBC specifying reading arrays as result sets in the first place.
fix(jdbc-v2): serve java.time array elements from source values inste…
polyglotAI-bot commentedon Nov 27, 2026
Recommendation: Keep open — fix needed
Open PR #3311 does not fix the issue's steps: with its diff, the three
getObjectcalls still fail. It changes only theBinaryStreamReader.ArrayValuepath, but jdbc-v2 reads an array as aListby default. It does not cover theTime64fraction loss either; if #3311 closes this issue, that part needs its own issue.main: Reproduced on main — the three calls fail with the reported error; aTime64element loses its whole fraction, with no error.Analysis:
ArrayResultSet.java:157throws becauseValueConvertersgivesjava.sql.Date,Time, andTimestamponly an identity and aStringconversion (ValueConverters.java:110-115). The elements have these classes because jdbc-v2 reads an array as aListby default (JdbcConfiguration.java:568) and converts each element inJdbcUtils.convert(JdbcUtils.java:331,:420-426). The second defect in the comments:JdbcUtils.java:426makes aTime64element withTime.valueOf(LocalTime), which drops the whole fraction, not only the part below milliseconds (12:34:56.123456789becomes12:34:56.000).Reproduction: complete program and output
Changed from the issue's steps: one table with the three types, a
Date32row column as a contrast, and aTime64(9)element read withgetArray().Output on
main(8480ca001), ClickHouse 26.11.2.4:Output with the diff of PR #3311:
Automated triage by Polyglot AI. A maintainer makes the final decision.