-
Notifications
You must be signed in to change notification settings - Fork 614
[jdbc-v2, client-v2] Fix configuration handling by normalizing it. #2470
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
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 PR streamlines client settings handling by migrating to a typed Map<String, Object> approach, enhances JSON handling in JDBC tests, and adds table-name parsing in the SQL parser.
- Added table name extraction in
ParsedPreparedStatementand logged it in the SQL parser tests. - Refactored client-side configuration to use
ClientConfigPropertiesand typed maps. - Cleaned up debug output in tests and updated expected values to match new settings behavior.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java | Added debug println for table extraction in parser tests. |
| jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java | Switched from getConnection() to getJdbcConnection(), enabled JSON test, and adjusted annotations. |
| jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/ParsedPreparedStatement.java | Added enterTableExprIdentifier to capture table identifiers. |
| client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java | Removed leftover debug println. |
| client-v2/src/test/java/com/clickhouse/client/HttpTransportTests.java | Updated expected async_insert value in mock server test. |
| client-v2/src/test/java/com/clickhouse/client/ClientTests.java | Adjusted expected configuration size counts. |
| client-v2/src/main/java/com/clickhouse/client/api/query/QuerySettings.java | Made rawSettings final, added constructor, updated httpHeader usage. |
| client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java | Refactored to use typed config map, removed MapUtils, and updated HTTP client setup. |
| client-v2/src/main/java/com/clickhouse/client/api/query/QuerySettings.java | Ensured consistent builder chaining and default initialization. |
| client-v2/src/main/java/com/clickhouse/client/api/ClientConfigProperties.java | Expanded property definitions, added parsing logic for typed values. |
| client-v2/src/main/java/com/clickhouse/client/api/Client.java | Migrated to Map<String, Object> config, merged client and operation settings. |
| clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseServerForTest.java | Removed unreachable debug exception block. |
Comments suppressed due to low confidence (2)
jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java:278
- [nitpick] Remove or replace this debug
println. Consider asserting on the extracted table name instead of printing to stdout.
System.out.println(stmt.getTable());
client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java:500
- This method no longer handles server settings (keys starting with
ClientConfigProperties.SERVER_SETTING_PREFIX), so server-side settings inrequestConfigwon't be added as query parameters. Reintroduce iteration overrequestConfigfor keys with the server setting prefix and add them viareq.addParameter(...).
private void addQueryParams(URIBuilder req, Map<String, Object> requestConfig) {
client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.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.
Other comments (3)
- client-v2/src/main/java/com/clickhouse/client/api/Client.java (1201-1201) Creating a new InsertSettings object with just the merged settings map might lose any custom behavior or state in the original settings object. Consider adding a copy constructor to InsertSettings or a method to apply settings from one object to another while preserving other state.
- jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java (278-278) This appears to be a debug print statement that was likely added during development. Consider removing it before merging.
- client-v2/src/main/java/com/clickhouse/client/api/query/QuerySettings.java (25-29) The constructor ordering might cause issues. The default constructor is calling a constructor that's defined after it. Consider reordering the constructors to have the parameterized constructor first, followed by the default constructor.
💡 To request another review, post a new comment with "/windsurf-review".
| try (Connection conn = getJdbcConnection(props)) { | ||
| try (Statement stmt = conn.createStatement()) { | ||
| try (ResultSet rs = stmt.executeQuery("SELECT * FROM test_json ORDER BY order")) { | ||
| assertTrue(rs.next()); | ||
| assertEquals(rs.getString("json"), json); | ||
|
|
||
| assertEquals(rs.getString("json"), serverJson); |
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.
The JSON test now correctly configures server settings for JSON handling, but it would be more comprehensive to also test retrieving the JSON as an object (using getObject("json")) and verify its structure, not just the string representation.
Client V2 CoverageCoverage Report
Class Coverage
|
| boolean hasPassword = this.configuration.containsKey(ClientConfigProperties.PASSWORD.getKey()); | ||
| boolean customHttpHeaders = this.configuration.containsKey(ClientConfigProperties.httpHeader(HttpHeaders.AUTHORIZATION)); | ||
|
|
||
| if (!(useSslAuth || hasAccessToken || hasUser || hasPassword || customHttpHeaders)) { |
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.
Do we want to mention what exactly is missing
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 when nothing is specified. That we say in the exception message
| boolean customHttpHeaders = this.configuration.containsKey(ClientConfigProperties.httpHeader(HttpHeaders.AUTHORIZATION)); | ||
|
|
||
| if (!(useSslAuth || hasAccessToken || hasUser || hasPassword || customHttpHeaders)) { | ||
| throw new IllegalArgumentException("Username and password (or access token or SSL authentication or pre-define Authorization header) are required"); |
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.
Do we want to wrap it as a client exception?
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 think this is fine - it is not even a client yet.
|
The PR message is misleading |
Summary
Closes #2359
Checklist
Delete items not relevant to your PR: