feat(rust_snuba): Add native ClickHouse client with RowBinary support #7703
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
Add infrastructure for using the official
clickhousecrate with RowBinary format for improved insert performance. The native client is fully wired up and can be enabled per-storage via configuration.Key Changes
Native client infrastructure (
src/strategies/clickhouse/client.rs):InsertableRowstrait for type-erased row insertion with type-aware batch mergingTypedRows<T>wrapper implementingInsertableRowsfor anyT: clickhouse::RowNativeClickhouseClientwith retry logic matching HTTP client behaviorDual-path batch support (
src/types.rs):typed_rows: Option<Arc<dyn InsertableRows>>toInsertBatchandBytesInsertBatchBytesInsertBatch::merge()preserves typed rows when types matchInsertBatch::from_rows_with_typed()for processors to provide both JSON and typed rowsNative writer step (
src/strategies/clickhouse/writer_v2.rs):NativeClickhouseWriterStepuses native client whentyped_rowsavailableConfiguration (
src/config.rs,src/factory_v2.rs):use_native_client: booloption toClickhouseConfigProcessor updates:
eap_items.rs- Refactored to remove#[serde(flatten)](incompatible withRowderive)clickhouse::Rowderive toEAPItemstructHow to Enable
To use the native RowBinary client for a processor:
clickhouse::Rowderive to the row structInsertBatch::from_rows()toInsertBatch::from_rows_with_typed()use_native_client: truein the storage's ClickHouse configTest plan
🤖 Generated with Claude Code