Added getting arrays of objects and other types of arrays#2747
Open
Added getting arrays of objects and other types of arrays#2747
Conversation
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
|
| * @return array of objects, or {@code null} if the value is null | ||
| * @throws com.clickhouse.client.api.ClientException if the column is not an array type | ||
| */ | ||
| <T> T getObjectArray(int index); |
There was a problem hiding this comment.
Misleading generic return type causes ClassCastException at runtime
Medium Severity
The getObjectArray methods in ClickHouseBinaryFormatReader are declared as <T> T but the implementation always returns Object[]. The Javadoc suggests Integer[][] as a valid type parameter, but this will cause a ClassCastException at runtime because the compiler inserts an implicit checkcast. The GenericRecord interface correctly declares the return type as Object[] for the same method. Using Object[] here instead of <T> T would be consistent and type-safe.
Additional Locations (1)
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
getObjectArrayto getObject[]Array(Tuple())Closes #2738
Checklist
Delete items not relevant to your PR:
Note
Medium Risk
Touches core RowBinary array decoding and record APIs; behavior changes (e.g.,
getStringArrayhandling of enum arrays and new object-array conversions) could affect existing callers and performance for large/nested arrays.Overview
Adds
getObjectArraytoClickHouseBinaryFormatReaderandGenericRecord(plusBinaryReaderBackedRecord/MapBackedRecord/AbstractBinaryFormatReaderimplementations) to returnObject[]for any ClickHouseArray(...), including recursively converting nested arrays into nestedObject[].Improves array accessors:
getStringArraynow also supportsArray(Enum*)by returning enum names, and the array-related Javadocs/error messages were clarified. Adds extensive unit and integration coverage for 1D/2D/3D arrays, empty arrays, and mixed element types (e.g.,UInt64,DateTime,FixedString, enums).Written by Cursor Bugbot for commit 9b8cf35. This will update automatically on new commits. Configure here.