enhancement(clickhouse sink): add Arrow IPC compression#25758
enhancement(clickhouse sink): add Arrow IPC compression#25758benjamin-awd wants to merge 2 commits into
Conversation
| #[configurable_component] | ||
| #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ArrowIpcCompression { |
There was a problem hiding this comment.
Took this implementation from the Datadog Zerobus sink to make it easier to consolidate in a follow-up PR
vector/src/sinks/databricks_zerobus/config.rs
Lines 53 to 70 in 0f7f98c
Moving it here instead of re-defining it in the Clickhouse sink since anything that implements Arrow Stream IPC will likely want to use these compression options
cc @flaviofcruz
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a07062340
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
3a07062 to
ce72f8f
Compare
…am encoding Adds a `compression` option to the clickhouse sink's `arrow_stream` batch encoding for block-level compression of the Arrow IPC record batch buffers (`none`, `lz4_frame`, or `zstd`, defaulting to `none`). Compression is applied inside the IPC stream so each column buffer is compressed independently, using substantially less CPU than an equivalent whole-payload HTTP `gzip` `Content-Encoding` at a comparable ratio. Enabling compression requires ClickHouse 23.11 or newer; older servers accept the insert but cannot read compressed Arrow IPC, so the sink validates the server version at startup and rejects the configuration on older servers. The ArrowIpcCompression enum mirrors databricks_zerobus's Compression (variant names, From conversion, skip_serializing_if) so the two can be consolidated into a shared codecs type in a follow-up.
ce72f8f to
6ae87cc
Compare
… compression is enabled The sink's top-level `compression` defaults to `gzip`, so enabling Arrow IPC buffer compression without also setting `compression: none` would gzip a payload that already contains compressed Arrow buffers, wasting CPU for negligible gain. When Arrow IPC compression is enabled, force the HTTP `compression` to `none` and log that it was disabled, so the IPC compression path does not double-compress by default.
6ae87cc to
18fe83d
Compare
Summary
Adds a
compressionoption (none|lz4_frame|zstd, defaultnone) to theclickhousesink'sarrow_streambatch encoding. It compresses each column buffer inside the Arrow IPC stream, so ClickHouse decompresses it on ingest.Today the only way to compress an
arrow_streampayload is a whole-payload HTTPgzipContent-Encoding— good on size, heavy on CPU. IPC compression is much cheaper (see issue for benchmark)Note: Compressed Arrow IPC needs ClickHouse ≥ 23.11 (both
lz4andzstd). Older servers accept the insert but can't read typical small compressed batches (Code: 33 CANNOT_READ_ALL_DATA) and would silently drop data, so the sink checks the server version at startup and rejectscompressionon older servers.Default is
none, so existing configs are unaffected.Vector configuration
How did you test this PR?
lib/codecs): compressed streams round-trip back to the sameRecordBatchand are smaller than uncompressed; version parsing and the minimum-version check.insert_events_arrow_format_{zstd,lz4}_compression— insert and read back; skip below 23.11.arrow_compression_rejected_on_old_clickhouse— the sink refuses to build with compression on ClickHouse < 23.11.Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
ArrowStreamformat #24373Notes
@vectordotdev/vectorto reach out to us regarding this PR.pre-pushhook, please see this template.make fmtmake check-clippy(if there are failures it's possible some of them can be fixed withmake clippy-fix)make testgit merge origin masterandgit push.Cargo.lock), pleaserun
make build-licensesto regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.