-
Notifications
You must be signed in to change notification settings - Fork 614
[jdbc-v2] Handling Time Time64 in JDBC #2682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for converting ClickHouse Time and Time64 types to java.sql.Time in the JDBC driver, even though java.sql.Time has limitations with negative values and lacks convenient APIs.
Key changes:
- Implements conversion logic from
Time/Time64tojava.sql.Timein utility methods and ResultSet implementation - Adds comprehensive test coverage for the new Time type conversions
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java | Adds tests validating Time/Time64 conversions to java.sql.Time and ensures proper exception handling for invalid conversions |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java | Implements conversion logic for Integer/Long values to Time objects |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java | Updates getTime() method to handle Time and Time64 data types from ClickHouse |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| public static Object convertObject(Object value, Class<?> type) throws SQLException { | ||
| public static Object convertObject(Object value, Class<?> type, ClickHouseColumn column) throws SQLException { |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new parameter column is added to the method signature but is never used in the method body. Either use this parameter for type-specific conversion logic or remove it to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other comments (2)
-
jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java (1051-1051)
The nanosecond conversion in the Time/Time64 case might lose precision. Consider rounding instead of truncating when converting nanoseconds to milliseconds:
return new Time(instant.getEpochSecond() * 1000L + Math.round(instant.getNano() / 1_000_000.0)); - jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java (1051-1051) The Time/Time64 case doesn't use the provided calendar parameter, unlike the DateTime case. This could lead to inconsistent behavior when a custom calendar is provided. Consider using the calendar for Time/Time64 types as well.
💡 To request another review, post a new comment with "/windsurf-review".
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java
Outdated
Show resolved
Hide resolved
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
|
/windsurf review |
|


Summary
Time/Time64 convertion tojava.sql.Time` even last do not support negative time and is not convenient to work with.Previously
TimeandTime64would be read asIntegerandLongrespectively becausejava.sql.Timedoesn't support negative dates and is inconvenient to work with. But this conversion may be useful in limited cases and logically correct as ClickHouse supportsTimetype.Checklist
Delete items not relevant to your PR: