[client-v2] Fixed converting integers thru decimal#2814
[client-v2] Fixed converting integers thru decimal#2814
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes loss of precision when converting integer values to BigDecimal in the client-v2 binary reader path (addressing #2748), ensuring large Int64/UInt64/... values are not truncated during conversion.
Changes:
- Update numeric-to-
BigDecimalconversion to avoiddouble-based conversion for integer types (use integral/string-based conversion instead). - Align serialization helpers to use
NumberConverterforBigInteger/BigDecimalconversions in a few numeric cases. - Add a focused unit test covering
getBigDecimal()for integer widths from 8 to 256 bits (signed/unsigned).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| client-v2/src/test/java/com/clickhouse/client/api/data_formats/ClickHouseBinaryFormatReaderTest.java | Adds regression test ensuring integer types (Int8..Int256/UInt8..UInt256) convert to BigDecimal without truncation. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/ValueConverters.java | Fixes Number -> BigDecimal conversion to preserve integer precision. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java | Routes decimal and big-int serialization through NumberConverter for consistency. |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/NumberConverter.java | Fixes toBigDecimal() to preserve precision for integer Number types (no double truncation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Outdated
Show resolved
Hide resolved
Client V2 CoverageCoverage Report
Class Coverage
|
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java
Show resolved
Hide resolved
client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java
Outdated
Show resolved
Hide resolved
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
mzitnik
left a comment
There was a problem hiding this comment.
Looks like we have partial coverage from tests coverage from new code is less than 80%
Another qestions currently we are running for integration prespective should we also tests it from JDBC prepective (should also support implicit conversions)
mzitnik
left a comment
There was a problem hiding this comment.
Lets try to extend our coverage test
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/ValueConverters.java
Outdated
Show resolved
Hide resolved
client-v2/src/test/java/com/clickhouse/client/internal/SerializerUtilsTests.java
Show resolved
Hide resolved
|



Summary
Closes #2748
Checklist
Delete items not relevant to your PR: