Merged
Conversation
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.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
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for reading and writing byte[] as binary strings in the JDBC driver, treating strings as byte arrays for compatibility with binary data operations.
Changes:
- Added
convertToUnhexExpression()utility to encodebyte[]asunhex(<hexstring>)SQL expressions forPreparedStatement#setBytes - Extended
ResultSet#getBytesand reader methods to return UTF-8 bytes of String values or raw address bytes of InetAddress objects - Refactored
AbstractBinaryFormatReaderto route column-name-based getters through index-based implementations for consistency
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java | Updated test to use plain SELECT ? instead of Array(Int8) cast for setBytes |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcDataTypeTests.java | Added integration tests for IP address byte retrieval and string/fixed-string round-tripping via setBytes/getBytes |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java | Introduced convertToUnhexExpression() to hex-encode byte arrays as SQL unhex expressions |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java | Swapped getBytes implementation to call index-based method from name-based variant |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java | Added byte[] encoding via unhex expression in encodeObject() |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java | Refactored to consolidate name-based getters onto index-based logic and added String/InetAddress→byte[] conversion in getPrimitiveArray() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcUtils.java
Outdated
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
Outdated
Show resolved
Hide resolved
kurnoolsaketh
left a comment
There was a problem hiding this comment.
besides my two comments below, the changes here look fine 👍 - most of this diff is code refactoring in AbstractBinaryFormatReader. Please get @mzitnik's feedback before merging.
...rc/main/java/com/clickhouse/client/api/data_formats/internal/AbstractBinaryFormatReader.java
Show resolved
Hide resolved
|
kurnoolsaketh
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
PreparedStatement#setBytesused -byte[]encoded asunhex(<hexstring>)that will let write binary stringsResultSet#getBytesused - thenbyte[]of String object will be returned. Note: still not optimal and internally logic will be changed to store strings asbyte[]and create them on demand.Checklist
Delete items not relevant to your PR:
Note
Medium Risk
Changes JDBC parameter encoding and binary-format value coercion for
byte[], which can affect howString/FixedStringand IP types are serialized/deserialized; covered by new integration/unit tests but touches core ResultSet/PreparedStatement paths.Overview
Adds end-to-end support for treating
byte[]as binary strings in JDBC.PreparedStatement#setBytesnow serializesbyte[]as a ClickHouseunhex('<hex>')expression (via newJdbcUtils.convertToUnhexExpression/decodeHexStringhelpers) to preserve raw bytes.On the read path,
ResultSet#getBytes(int)is switched to use the binary reader’sgetByteArray(index)directly, and the underlyingAbstractBinaryFormatReaderis updated to allowgetByteArray()to coerceString/FixedStringvalues (UTF-8) andInetAddressvalues (raw address bytes) intobyte[]. Tests are added/updated to validate bytes round-tripping for strings, fixed strings, and IP address columns, and the performance module’s Testcontainers ClickHouse dependency is updated totestcontainers-clickhousev2.0.2.Written by Cursor Bugbot for commit 04513dd. This will update automatically on new commits. Configure here.