-
Notifications
You must be signed in to change notification settings - Fork 614
[Client-V2, JDBC] Fix problem reading JSON nested arrays #2601
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
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
|
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.
Other comments (2)
- client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java (752-753) This test is tightly coupled to the implementation by directly casting to `BinaryStreamReader.ArrayValue`. Consider using a more generic approach that doesn't depend on specific implementation classes, such as verifying the behavior rather than the type.
-
clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java (376-376)
The variable name was updated to `tmpBinTag2Type` for better readability, but the method call still uses the old name pattern. For consistency, this should be updated too.
tmpBinTag2Type.put(type.getBinTag(), type);
💡 To request another review, post a new comment with "/windsurf-review".
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java
Show resolved
Hide resolved
client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java
Outdated
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java
Outdated
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.
Pull Request Overview
This pull request fixes issues reading data from JSON columns with nested arrays of objects or other multi-level nested objects in both the Client-V2 and JDBC components.
- Resolves problems with serialization and deserialization of complex JSON structures containing nested arrays
- Updates dynamic type handling for better support of nested data structures
- Adds comprehensive test coverage for various JSON nested array scenarios
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| jdbc-v2/src/test/java/com/clickhouse/jdbc/JdbcIntegrationTest.java | Modified test infrastructure methods to throw exceptions instead of returning booleans |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java | Added comprehensive JSON nested array tests and fixed timezone handling in time tests |
| client-v2/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java | Added extensive dynamic type tests for nested structures, JSON, and variant types |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/SerializerUtils.java | Fixed Time64 serialization calculation and improved dynamic type tag handling |
| client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java | Comprehensive refactoring of dynamic data reading with proper handling of all data types |
| clickhouse-data/src/main/java/com/clickhouse/data/ClickHouseDataType.java | Removed binary tags from geometric types and cleaned up imports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or 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/src/test/java/com/clickhouse/client/datatypes/DataTypeTests.java
Outdated
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java
Show resolved
Hide resolved
client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java
Outdated
Show resolved
Hide resolved
mzitnik
left a comment
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.
Also we did a lot of work related to other types do we have a good test coverage for that?
| } | ||
| return ClickHouseColumn.of("v", type, false, 0, 0); | ||
| case JSON: { | ||
| byte serializationVersion = readByte(); |
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.
serializationVersion not in use? Seems to be redundant, or any other plans?
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.
I need to figure out. but seems not in use.
| } | ||
| case Nested: { | ||
| int size = readVarInt(input); | ||
| StringBuilder nested = new StringBuilder(); |
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.
Since we have estimated size can we init with StringBuilder with size
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.
it will be a guessing. Default size of StringBuilder is 16 chars.
So I think we may define int DEFAULT_STRING_BUILDER_SIZE = 100 should be good.
Here is an example of tuple definition with total length of 103 chars/bytes:
Tuple(productId Int32, name String, price Float32, added Date, removed Date, storeId UUID, flags UInt8)
May be we need to make it configurable or may be add some metric first.
|
|
||
| assertTrue(rs.next()); | ||
| Object jsonObj = rs.getObject(1); | ||
| assertTrue(rs.next()); |
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.
Should we test the content?
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.
Yes.
I was relying on tests in the client, but here is another story.
Will add checks.
| createProperties.put(ClientConfigProperties.serverSetting("allow_experimental_time_time64_type"), "1"); | ||
| runQuery("CREATE TABLE test_time64 (order Int8, " | ||
| + "time Time('UTC'), time64 Time64(9) " | ||
| + "time Time, time64 Time64(9) " |
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.
This is the fix for falling tests on latest.
We had tests for other types. These changes are more code rearrangement to optimize multiple |
|


Summary
Closes #2598
Closes #2593
Closes #2102
Closes #2613
Checklist
Delete items not relevant to your PR: