Skip to content

ClickHouse: Upgrade JDBC driver from 0.3.2 to 0.9.6#1297

Open
alexey-milovidov wants to merge 2 commits intosqlancer:mainfrom
ClickHouse:fix-clickhouse-jdbc-driver
Open

ClickHouse: Upgrade JDBC driver from 0.3.2 to 0.9.6#1297
alexey-milovidov wants to merge 2 commits intosqlancer:mainfrom
ClickHouse:fix-clickhouse-jdbc-driver

Conversation

@alexey-milovidov
Copy link
Contributor

Summary

  • Upgrade JDBC driver from ru.yandex.clickhouse:clickhouse-jdbc:0.3.2 to com.clickhouse:clickhouse-jdbc:0.9.6 (with all classifier)
  • Update all imports from com.clickhouse.client.ClickHouseDataType to com.clickhouse.data.ClickHouseDataType
  • Add "Magic is not correct" to expected errors as safety net for JDBC compression protocol issues

Problem

The old JDBC driver (0.3.2) fails to properly handle compressed error responses from the ClickHouse server. When a query fails (e.g., ILLEGAL_TYPE_OF_ARGUMENT during table creation), the server sends an error response, but the old driver tries to decompress it using ClickHouse native LZ4 and fails with:

java.io.IOException: Magic is not correct - expect [-126] but got [-63]
    at com.clickhouse.client.data.ClickHouseLZ4InputStream.readNextBlock

This prevents SQLancer from matching the error against the expected errors list, causing it to throw AssertionError for every table creation failure. As a result, all 6 ClickHouse tests report "Executed 0 queries" because database generation never completes.

The new driver (0.9.6) from com.clickhouse group properly handles error responses regardless of compression settings.

alexey-milovidov and others added 2 commits March 1, 2026 05:02
ClickHouse PR ClickHouse/ClickHouse#81835
added a check that forbids creating tables without insertable columns
(e.g., tables with only MATERIALIZED or ALIAS columns). Since SQLancer's
random table generator can produce such definitions, ClickHouse now
returns EMPTY_LIST_OF_COLUMNS_PASSED, which should be treated as an
expected error rather than causing an AssertionError.

The table creation retry loop in ClickHouseProvider.generateDatabase
already handles expected errors by regenerating the table definition.
The old driver (ru.yandex.clickhouse:clickhouse-jdbc:0.3.2) failed to
decompress error responses from the server, throwing
"Magic is not correct" IOException instead of reporting the actual
ClickHouse error message. This caused SQLancer to treat expected errors
(like ILLEGAL_TYPE_OF_ARGUMENT) as assertion failures, because the
JDBC exception message didn't contain the expected error substrings.

Changes:
- Update Maven dependency from ru.yandex.clickhouse:clickhouse-jdbc:0.3.2
  to com.clickhouse:clickhouse-jdbc:0.9.6 (with "all" classifier)
- Update all imports from com.clickhouse.client.ClickHouseDataType
  to com.clickhouse.data.ClickHouseDataType (package was renamed)
- Add "Magic is not correct" to expected errors as safety net

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mrigger
Copy link
Contributor

mrigger commented Mar 2, 2026

Thanks a lot for the PR! Currently, I see the following CI failure:

[INFO] -------------------------------------------------------------
Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/sqlancer/sqlancer/test/sqlancer/clickhouse/ast/ClickHouseBinaryComparisonOperationTest.java:[8,8] The import com.clickhouse.client.ClickHouseDataType cannot be resolved
Error:  /home/runner/work/sqlancer/sqlancer/test/sqlancer/clickhouse/ast/ClickHouseBinaryComparisonOperationTest.java:[81,14] ClickHouseDataType cannot be resolved to a type
Error:  /home/runner/work/sqlancer/sqlancer/test/sqlancer/clickhouse/ast/ClickHouseBinaryComparisonOperationTest.java:[81,48] ClickHouseDataType cannot be resolved to a type
Error:  /home/runner/work/sqlancer/sqlancer/test/sqlancer/clickhouse/ast/ClickHouseBinaryComparisonOperationTest.java:[81,75] ClickHouseDataType cannot be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants