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
Adds ability to read and write byte[] as binary strings.
When PreparedStatement#setBytes used - byte[] encoded as unhex(<hexstring>) that will let write binary strings
When ResultSet#getBytes used - then byte[] of String object will be returned. Note: still not optimal and internally logic will be changed to store strings as byte[] and create them on demand.
Checklist
Delete items not relevant to your PR:
Unit and integration tests covering the common scenarios were added
A human-readable description of the changes was provided to include in CHANGELOG
Medium Risk
Changes core value encoding/decoding paths for byte[] and refactors many reader getters to flow through index-based logic, which could affect type conversions and null/error handling across result parsing.
Overview
Adds first-class binary-string handling for byte[] across the v2 client/JDBC stack.
PreparedStatement#setBytes now serializes byte[] as a ClickHouse unhex('...') SQL expression via a new JdbcUtils.convertToUnhexExpression() helper. ResultSet#getBytes is updated to read bytes by column index/label through the binary reader, and the client-side AbstractBinaryFormatReader#getByteArray can now return byte[] not only for arrays but also when the underlying value is a String (UTF-8) or InetAddress (raw address bytes), alongside a broader refactor to route name-based getters through index-based implementations.
Integration tests were extended to cover reading IP columns via getBytes, inserting/retrieving string/fixed-string values using setBytes/getBytes, and adjusting testSetBytes semantics away from treating bytes as an Array(Int8) parameter.
Written by Cursor Bugbot for commit 492f659. This will update automatically on new commits. Configure here.
The reason will be displayed to describe this comment to others. Learn more.
String/InetAddress handling ignores componentType parameter causing type mismatch
Medium Severity
The getPrimitiveArray method ignores the componentType parameter when handling String and InetAddress values, always returning byte[]. This causes a ClassCastException when calling methods like getIntArray(), getFloatArray(), etc. on columns containing String or InetAddress values. The String/InetAddress conversion to byte[] should only occur when componentType equals byte.class.
The reason will be displayed to describe this comment to others. Learn more.
Missing closed check causes NPE on closed ResultSet
Medium Severity
The refactored getBytes(String columnLabel) method removed the checkClosed() call that existed in the old implementation. It now directly calls getSchema().nameToColumnIndex(columnLabel) before delegating to getBytes(int). Since getSchema() accesses reader.getSchema() and the close() method sets reader = null, calling this method on a closed ResultSet throws a NullPointerException instead of the expected SQLException with "ResultSet is closed" message.
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
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 core value encoding/decoding paths for
byte[]and refactors many reader getters to flow through index-based logic, which could affect type conversions and null/error handling across result parsing.Overview
Adds first-class binary-string handling for
byte[]across the v2 client/JDBC stack.PreparedStatement#setBytesnow serializesbyte[]as a ClickHouseunhex('...')SQL expression via a newJdbcUtils.convertToUnhexExpression()helper.ResultSet#getBytesis updated to read bytes by column index/label through the binary reader, and the client-sideAbstractBinaryFormatReader#getByteArraycan now returnbyte[]not only for arrays but also when the underlying value is aString(UTF-8) orInetAddress(raw address bytes), alongside a broader refactor to route name-based getters through index-based implementations.Integration tests were extended to cover reading IP columns via
getBytes, inserting/retrieving string/fixed-string values usingsetBytes/getBytes, and adjustingtestSetBytessemantics away from treating bytes as anArray(Int8)parameter.Written by Cursor Bugbot for commit 492f659. This will update automatically on new commits. Configure here.