-
Notifications
You must be signed in to change notification settings - Fork 618
[client-v2,jdbc-v2] Fix reading Date/Time values #2727
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
base: main
Are you sure you want to change the base?
Conversation
…be stored as Integer
…is reduces number of conversions and makes logic simple
… dates are used for simpler reference
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Outdated
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
…ime value and actual time from it
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/MapBackedRecord.java
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
|
| * | ||
| * @return ClickHouseDataType | ||
| */ | ||
| public ClickHouseDataType getEffectiveDataType() { |
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.
What is the difference between getDataType and getEffectiveDataType
I see that we call getEffectiveDataType every time we get time data
Maybe we can prepare it in advance?
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.
effective data type refer to aggregate function. It was an existing code and I have put it here to avoid forgetting.
Yes, this is the plan that we know how to convert each field and will remove this switch statements - basically for each column we will have a list of converter and it will be getConeverterForTargetClass(column, targetClass) call.
Where dynamic or variant columns - they will have same approach but list of converters will be calculated for each row (not a big over header expected because lists of converters are pre-baked). We using this approach in ResultSet for Arrays.
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.
After discussion we decided that we need just pre-calculate this data type to avoid getter chain




Summary
Closes
Checklist
Delete items not relevant to your PR:
Note
Medium Risk
Medium risk because it changes the runtime types returned for
Date/Timecolumns (and their string/JDBC conversions), including a behavior change whereDateis no longer exposed asZonedDateTime, which can break downstream code relying on prior conversions.Overview
Client-v2 now decodes
Date/Date32asLocalDate(timezone-free) andTime/Time64as UTC-backedLocalDateTime, with newgetLocalTime()accessors and updatedgetString()/temporal getters to route through the appropriate typed value (includingDynamic/Variantcoercions).Adds
ClickHouseColumn.getEffectiveDataType()to consistently unwrapSimpleAggregateFunctioncolumns for conversion logic, improves null-handling for several getters (arrays, geo, inet, duration, enums), and updates the binary reader to emit the new date/time representations.JDBC v2 updates
ResultSetdate/time conversions to useLocalDateforDateandLocalDateTimeforTime, adds agetObject()shortcut forDate/Time/Timestamp, and extendsJdbcUtilsconversions (includingDurationfrom time values).Integration tests were added/updated to validate
Date/Timebehavior across time zones and support reading date/time values fromDynamic/Variant(plus refactoring/renaming of some JDBC tests).Written by Cursor Bugbot for commit b23d218. This will update automatically on new commits. Configure here.