You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
Adds ZSTD support for ClickHouse native block compression in client-v2 (and thus jdbc-v2), motivated by issue #3105: the server's default network_compression_method switched from LZ4 to ZSTD, breaking clients that only supported LZ4 (the workaround setting isn't available to read-only profiles). The decompression path (CompressedBlockInputStream, renamed from ClickHouseLZ4InputStream) now dispatches on the block-header magic byte (LZ4 / ZSTD / uncompressed); the compression path is refactored into an abstract CompressedBlockOutputStream with LZ4 and ZSTD subclasses, selected via a new compression.method client option (new CompressionMethod enum, new Client.Builder.compressionMethod()) whose default is ZSTD. zstd-jni moves from test-scope to a runtime dependency (bumped 1.5.7-6 → 1.5.7-20, cloud classifier) and its natives are bundled into the JDBC -all jar. Test files across clickhouse-client/http-client/jdbc/r2dbc pin v1 clients to network_compression_method=lz4, and new LZ4/ZSTD integration test variants are added.
What this impacts
client-v2 block (de)compression streams — the wire-format read/write hot path for all compressed queries and inserts
Public API surface: new CompressionMethod enum, Client.Builder.compressionMethod(), new compression.method config property; public classes ClickHouseLZ4InputStream/ClickHouseLZ4OutputStream renamed (removed)
jdbc-v2 packaging: zstd-jni native libraries now bundled in the -all artifact (jar size, platform matrix)
v1 test suites (clickhouse-client, http-client, jdbc, r2dbc) now force LZ4 — v1 itself gains no ZSTD support
Concerns
High rules fired: changes to client-v2 readers/writers (block stream layer), public API shape change (renamed/removed public stream classes), and large diff (1225+/647−, ~30 files) — consider reviewing the stream rework separately from the mechanical test pinning.
Default write compression method silently changes from LZ4 to ZSTD via COMPRESSION_METHOD default — a behavioral default change for all client-v2 users, not just a compatibility fix for reads.
Possible correctness regression: CompressedBlockOutputStream sizes compressedBuffer as bufferSize + 25, but the old LZ4 code used compressor.maxCompressedLength(bufferSize) + 15; incompressible input can exceed the new buffer and fail compression — reviewer should verify overflow handling for both codecs.
New runtime native dependency (zstd-jni JNI) in the hot path plus version bump and cloud classifier — supply-chain and platform-support surface worth a deliberate look.
v1 tests pinned to network_compression_method=lz4 narrows the tested surface (v1 vs new server defaults) rather than fixing v1 — acceptable if v1 is legacy, but worth confirming intent.
PR checklist items (tests, CHANGELOG confirmation) left unchecked, though CHANGELOG and tests are present in the diff.
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
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
Default block compression method on ClickHouse was switched from
LZ4toZSTD. This caused client to fail as it lacks new method support. One of workarounds was settingnetwork_compress_method(see https://clickhouse.com/docs/reference/settings/session-settings/network#network_compression_method) but is not possible for read-only user profiles.Now client detects compression method set in block header and (de)compresses it properly.
Closes #3105
Closes #3120
Checklist
Delete items not relevant to your PR: