[fix][io] Upgrade ClickHouse jdbc client version to 0.9.8#33
Conversation
|
Thanks for the fix, @jknetl — the driver bump looks correct for #32. One thing to flag before merge: CI hasn't actually run on this PR yet. The "Pulsar Connectors CI" workflow is sitting in the action_required state (pending maintainer approval for a first-time contributor), so neither the build nor the unit test job has executed. A maintainer will need to click "Approve and run workflows" so we get a green run before merging. A couple of caveats worth noting even once CI passes:
Once CI is approved/green and you can confirm a manual ClickHouse check, this is good to go from my side. 👍 |
Adds a Testcontainers-based integration test that verifies the ClickHouse JDBC sink can discover an existing table and write a record against a real ClickHouse server. This guards the driver upgrade in this PR: the test fails on the old driver (0.4.6) with "Not able to find table: pulsar_messages" at JdbcUtils.getTableId (issue apache#32) and passes on 0.9.8. The table is created and results are verified over ClickHouse's HTTP interface, so the JDBC driver under test is exercised only by the sink. - Add testcontainers-clickhouse to the version catalog. - Add test dependencies to the clickhouse module build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
I went ahead and added an integration test for this change (pushed as a commit on the branch) so the driver upgrade is actually validated against a real ClickHouse server.
The test is a genuine regression guard for #32 — red on the old driver, green on the new one:
One deliberate design choice: the table is created and the result is read back over ClickHouse's HTTP interface rather than JDBC, so the driver under test is exercised only by the sink. That's what makes the failure surface precisely at Changes in the added commit:
Verified locally on JDK 17 with Docker; full A couple of notes for whoever merges:
|
There was a problem hiding this comment.
Pull request overview
This PR upgrades the ClickHouse JDBC driver used by the Pulsar IO JDBC ClickHouse sink to address a metadata/table-discovery incompatibility with newer ClickHouse server versions (issue #32), and adds an integration test that reproduces the original failure mode against a real ClickHouse instance via Testcontainers.
Changes:
- Bump
com.clickhouse:clickhouse-jdbcfrom0.4.6to0.9.8. - Add a Testcontainers-based integration test that verifies
open()can discover an existing table and that a write succeeds. - Add the ClickHouse Testcontainers module and required Pulsar/Avro test dependencies for the new test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| jdbc/clickhouse/src/test/java/org/apache/pulsar/io/jdbc/ClickHouseJdbcSinkIntegrationTest.java | Adds an integration test to guard against the table-discovery regression from issue #32. |
| jdbc/clickhouse/build.gradle.kts | Adds test dependencies needed to run the new ClickHouse integration test. |
| gradle/libs.versions.toml | Updates ClickHouse JDBC driver version and adds the Testcontainers ClickHouse library alias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public void tearDown() throws Exception { | ||
| if (jdbcSink != null) { | ||
| jdbcSink.close(); | ||
| } | ||
| if (clickhouse != null) { | ||
| clickhouse.stop(); | ||
| } | ||
| } |
| private String httpQuery(String sql) throws Exception { | ||
| URL url = new URL("http://" + clickhouse.getHost() + ":" | ||
| + clickhouse.getMappedPort(8123) + "/"); | ||
| HttpURLConnection conn = (HttpURLConnection) url.openConnection(); | ||
| conn.setRequestMethod("POST"); | ||
| conn.setDoOutput(true); | ||
| conn.setRequestProperty("X-ClickHouse-User", clickhouse.getUsername()); | ||
| conn.setRequestProperty("X-ClickHouse-Key", clickhouse.getPassword()); | ||
| try (OutputStream os = conn.getOutputStream()) { | ||
| os.write(sql.getBytes(StandardCharsets.UTF_8)); | ||
| } | ||
| int code = conn.getResponseCode(); | ||
| try (InputStream is = code < 400 ? conn.getInputStream() : conn.getErrorStream()) { | ||
| String body = new String(is.readAllBytes(), StandardCharsets.UTF_8); | ||
| if (code >= 400) { | ||
| throw new RuntimeException("ClickHouse HTTP query failed (" + code + "): " + body); | ||
| } | ||
| return body; | ||
| } | ||
| } |
|
Thanks @david-streamlio for adding the test. I can confirm I succesfully tested it end to end against the ClickHouse server version 26.2.1. |
Updates ClickHouse jdbc driver to the latest version.
fixes #32