Skip to content

feat(connectors): Clickhouse Sink Connector#2886

Open
kriti-sc wants to merge 57 commits into
apache:masterfrom
kriti-sc:clickhouse-sink
Open

feat(connectors): Clickhouse Sink Connector#2886
kriti-sc wants to merge 57 commits into
apache:masterfrom
kriti-sc:clickhouse-sink

Conversation

@kriti-sc

@kriti-sc kriti-sc commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2539

Rationale

Clickhouse is a real-time data analytics engine, and very popular in modern analytics architectures.

What changed?

This PR introduces a Clickhouse Sink Connector that enables writing data from Iggy to Clickhouse.

The Clickhouse writing logic is heavily inspired by the official Clickhouse Kafka Connector.

Local Execution

  • Produced messages 30456 + 29060 rows with schema user_id: String, user_type: u8, email: String, source: String, state: String, created_at: DateTime, message: String using sample data producer.
  • Consumed messages using the Clickhouse sink and into the particular Clickhouse table.
  • Verified schema and number of rows in Clickhouse.
  • Added unit tests and e2e tests, both passing.

Images 1&2: Produced 30456 + 29060 rows into Iggy in two batches
Image 3: Verified schema and number of rows in Clickhouse

image image image

AI Usage

  1. Which tools? (e.g., GitHub Copilot, Claude, ChatGPT) Claude Code
  2. Scope of usage? (e.g., autocomplete, generated functions, entire implementation) generated functions
  3. How did you verify the generated code works correctly? Manual testing by producing data into Iggy and then running the sink and verifying insertion into Clickhouse, unit tests and e2e tests for different Clickhouse insert configurations.
  4. Can you explain every line of the code if asked? Yes

@codecov

codecov Bot commented Mar 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.56210% with 358 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.42%. Comparing base (8678ead) to head (11c2f47).

Files with missing lines Patch % Lines
...ore/connectors/sinks/clickhouse_sink/src/binary.rs 82.95% 122 Missing and 56 partials ⚠️
...ore/connectors/sinks/clickhouse_sink/src/schema.rs 76.45% 30 Missing and 75 partials ⚠️
...ore/connectors/sinks/clickhouse_sink/src/client.rs 72.68% 55 Missing and 10 partials ⚠️
core/connectors/sinks/clickhouse_sink/src/lib.rs 97.27% 3 Missing and 1 partial ⚠️
core/connectors/sinks/clickhouse_sink/src/sink.rs 60.00% 4 Missing ⚠️
core/connectors/sinks/clickhouse_sink/src/body.rs 98.80% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #2886       +/-   ##
=============================================
- Coverage     74.57%   47.42%   -27.15%     
  Complexity      937      937               
=============================================
  Files          1249     1252        +3     
  Lines        123564   110008    -13556     
  Branches      99837    86313    -13524     
=============================================
- Hits          92143    52172    -39971     
- Misses        28438    55018    +26580     
+ Partials       2983     2818      -165     
Components Coverage Δ
Rust Core 40.92% <82.56%> (-34.81%) ⬇️
Java SDK 58.57% <ø> (ø)
C# SDK 69.41% <ø> (-0.45%) ⬇️
Python SDK 81.06% <ø> (ø)
PHP SDK 83.57% <ø> (ø)
Node SDK 91.35% <ø> (+0.12%) ⬆️
Go SDK 40.25% <ø> (ø)
Files with missing lines Coverage Δ
core/connectors/sinks/clickhouse_sink/src/body.rs 98.80% <98.80%> (ø)
core/connectors/sinks/clickhouse_sink/src/lib.rs 97.27% <97.27%> (ø)
core/connectors/sinks/clickhouse_sink/src/sink.rs 60.00% <60.00%> (ø)
...ore/connectors/sinks/clickhouse_sink/src/client.rs 72.68% <72.68%> (ø)
...ore/connectors/sinks/clickhouse_sink/src/schema.rs 76.45% <76.45%> (ø)
...ore/connectors/sinks/clickhouse_sink/src/binary.rs 82.95% <82.95%> (ø)

... and 362 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs
@kriti-sc kriti-sc requested a review from abonander March 7, 2026 10:58
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added S-stale Inactive issue or pull request and removed S-stale Inactive issue or pull request labels Mar 17, 2026

@hubcio hubcio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall good direction, just needs a little bit polishing

Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/schema.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/client.rs
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
Comment thread core/connectors/sinks/clickhouse_sink/src/binary.rs Outdated
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added S-stale Inactive issue or pull request and removed S-stale Inactive issue or pull request labels Apr 2, 2026
@kriti-sc kriti-sc requested a review from hubcio April 3, 2026 19:56
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR.

Thank you for your contribution!

@github-actions github-actions Bot added S-stale Inactive issue or pull request and removed S-stale Inactive issue or pull request labels Apr 18, 2026
@kriti-sc

kriti-sc commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 2, 2026
@ryerraguntla

Copy link
Copy Markdown
Contributor

/author could you look into it

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 14, 2026
@kriti-sc

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Jun 14, 2026

/// Build a RowBinaryWithDefaults body.
/// Each `Payload::Json` message is serialised to binary using the table schema.
pub(crate) fn build_row_binary_body(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

body.rs:58-77 (build_row_binary_body) vs module doc body.rs:18-23 — propagates Err from serialize_row on first bad row, failing whole batch. Doc claims "mixed batch never causes complete failure" — true for json/string builders, false here. Fix: skip-and-log bad row (match other builders) or document fail-fast as intentional poison-pill in README Reliability section.

if attempts >= max_retries {
error!(
"Insert failed after {attempts} attempts (HTTP {status}): {body_text}"
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.rs:243-256 (insert) — Error::CannotStoreData used for BOTH retryable (429/5xx/network) and non-retryable 4xx. Other connectors doris_sink/influxdb_sink use Error::PermanentHttpError for 4xx, per SDK doc "so circuit breakers are not tripped by bad data" (sdk/src/lib.rs:420-425).
Fix: 4xx branch → Error::PermanentHttpError.

container: ContainerAsync<GenericImage>,
pub base_url: String,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixtures/clickhouse/container.rs:90-96 — ClickHouseContainer::start() missing.with_container_name(fixtures::unique_container_name("clickhouse")). postgres/influxdb fixtures set this; fixtures/mod.rs:32-36 docs iggy-test-* sweep convention (docker ps -aqf 'name=^iggy-test-'). Without it, container gets random testcontainers name, invisible to cleanup sweep, leaks on crash/SIGKILL. Fix: add the call.

@ryerraguntla

Copy link
Copy Markdown
Contributor

/author

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author PR is waiting on author response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement ClickHouse Sink Connector

6 participants