Repository navigation
feat(warehouse): clickhouse v2 loading - #7303
Merged
Merged
Conversation
achettyiitr
force-pushed
the
feat.clickhouse-v2-connection
branch
from
August 25, 2026 05:00
1de6d74 to
a51afbb
Compare
achettyiitr
force-pushed
the
feat.clickhouse-v2-loading
branch
from
August 25, 2026 05:40
5259cec to
c8688af
Compare
achettyiitr
force-pushed
the
feat.clickhouse-v2-connection
branch
from
August 25, 2026 08:13
487616e to
e6cb13f
Compare
achettyiitr
force-pushed
the
feat.clickhouse-v2-loading
branch
from
August 25, 2026 08:52
c8688af to
9d02d35
Compare
Loading for the v2 implementation: the S3 copy-engine path, the download path, and the block loop that streams every load file for a table through one batch per commitEvery rows. Independent of the DDL PR; either can merge first.
achettyiitr
force-pushed
the
feat.clickhouse-v2-loading
branch
from
August 25, 2026 09:27
9d02d35 to
2704d2d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #7303 +/- ##
==========================================
- Coverage 79.34% 79.04% -0.30%
==========================================
Files 609 611 +2
Lines 67963 68289 +326
==========================================
+ Hits 53922 53982 +60
- Misses 10876 11136 +260
- Partials 3165 3171 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1 task done
saikumarrs
reviewed
Aug 27, 2026
saikumarrs
left a comment
Member
There was a problem hiding this comment.
Three on the load path, all in places where v2 diverges from v1. The missing write bounds is the one I'd want settled before this goes behind a workspace flag — the other two are cheap.
🔒 Scanned for secrets using gitleaks 8.29.1
saikumarrs
approved these changes
Aug 28, 2026
loadByCopyCommand passes the access key and secret to the s3 table function as literals, and the v2 middleware was constructed without a secrets regex, so the slow query log wrote both at Info once a copy crossed the threshold. The s3 table function takes positional arguments, so unlike redshift, snowflake and deltalake there is no label to anchor on: the pattern keeps the load folder and masks the two values that follow it. Reordering the argument list would silently reopen this, hence the test. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
🔒 Scanned for secrets using gitleaks 8.29.1
🔒 Scanned for secrets using gitleaks 8.29.1
🔒 Scanned for secrets using gitleaks 8.29.1
ItsSudip
approved these changes
Aug 28, 2026
achettyiitr
added a commit
that referenced
this pull request
Aug 28, 2026
# Description Wires the v2 ClickHouse implementation into the factory behind a flag, and makes the integration suite run against whichever implementation is under test. Stacked on [#7303](#7303) — review that one first. ### The flag `manager.go` resolves ClickHouse through a small `newClickhouse` helper. With `Warehouse.clickhouse.useV2Driver` unset — the default — nothing changes: it returns `clickhouse.New` exactly as before. The factories only receive a destination type, so the choice resolves once at construction and applies process-wide. That makes the rollout unit a deployment rather than a destination, which is worth knowing before turning it on anywhere. ### One suite, both implementations Every subtest is shared, so coverage cannot drift between v1 and v2. Which implementation runs is chosen by `CLICKHOUSE_USE_V2`, and the warehouse matrix carries a `clickhouse-v2` leg that sets it, so each gets its own job, its own log and its own re-run. Unset means v1, so a bare `go test ./warehouse/integrations/clickhouse/...` keeps working. ### Verification connects with the driver under test Previously every connection came from `sql.Open("clickhouse", …)`, registered by `github.com/ClickHouse/clickhouse-go` — v1. The suite ran twice but always verified through a v1 handle. That hides things rather than merely being untidy. v1 cannot represent every type v2 can create, and a read often survives anyway because the query coerces the column to `String`; only a write surfaces the gap, and then it fails inside the driver rather than at the server. Any v2-only type is unverifiable this way. Connections now go through a single `connectDB` closure that picks the driver from the implementation under test. That also removes the DSN string which was duplicated at seven call sites, and `initializeClickhouseClusterMode` takes the same closure so its distributed-table DDL runs over the right driver too. ### Also here - `secure_test.go` — TLS coverage against a real server, with the certificate pair generated per run into `t.TempDir()` rather than committed, following the pattern in `warehouse/integrations/tunnelling/connect_test.go`. It uses dockertest rather than testcompose so the existing suite is left alone. - `docker-compose.clickhouse-v2.yml` and `docker-compose.clickhouse-cluster-v2.yml` — v2 runs against ClickHouse 25.8, where v1 runs against 21. ## Linear Ticket - Resolves INT-7018, INT-7019 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used. --------- Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Aug 31, 2026
Merged
itsmihir
pushed a commit
that referenced
this pull request
Aug 31, 2026
🤖 I have created a release *beep* *boop* --- ## [1.85.0-rc.1](v1.84.0...v1.85.0-rc.1) (2026-08-31) ### Features * backend config v2 resolver with stub mapper ([#7275](#7275)) ([267b973](267b973)) * **warehouse:** clickhouse v2 connection and schema ([#7301](#7301)) ([2eb1fa6](2eb1fa6)) * **warehouse:** clickhouse v2 ddl operations ([#7302](#7302)) ([f2887c5](f2887c5)) * **warehouse:** clickhouse v2 loading ([#7303](#7303)) ([3e48618](3e48618)) * **warehouse:** enable the clickhouse v2 driver behind a flag ([#7311](#7311)) ([3ce1da5](3ce1da5)) ### Bug Fixes * race conditions while counting initial pending events can cause wrong counting ([#7292](#7292)) ([3efa718](3efa718)) * replay destinations not using the config corresponding to their connected source type ([#7307](#7307)) ([ee7aa93](ee7aa93)) * **router:** abort router-transform on proactive invalid_grant instead of retrying (INT-6779) ([#7175](#7175)) ([4d7348d](4d7348d)) * tracking plan merged config is cached without its event type ([#7314](#7314)) ([624dd5c](624dd5c)) ### Miscellaneous * setattr/delattr hardening ([#7291](#7291)) ([2855af4](2855af4)) * sync release v1.84.0 to main branch ([#7306](#7306)) ([fa102b7](fa102b7)) * webhook reasons ([#7294](#7294)) ([c298d59](c298d59)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir
pushed a commit
that referenced
this pull request
Sep 1, 2026
🤖 I have created a release *beep* *boop* --- ## [1.85.0](v1.84.0...v1.85.0) (2026-08-31) ### Features * backend config v2 resolver with stub mapper ([#7275](#7275)) ([267b973](267b973)) * **warehouse:** clickhouse v2 connection and schema ([#7301](#7301)) ([2eb1fa6](2eb1fa6)) * **warehouse:** clickhouse v2 ddl operations ([#7302](#7302)) ([f2887c5](f2887c5)) * **warehouse:** clickhouse v2 loading ([#7303](#7303)) ([3e48618](3e48618)) * **warehouse:** enable the clickhouse v2 driver behind a flag ([#7311](#7311)) ([3ce1da5](3ce1da5)) ### Bug Fixes * race conditions while counting initial pending events can cause wrong counting ([#7292](#7292)) ([3efa718](3efa718)) * replay destinations not using the config corresponding to their connected source type ([#7307](#7307)) ([ee7aa93](ee7aa93)) * **router:** abort router-transform on proactive invalid_grant instead of retrying (INT-6779) ([#7175](#7175)) ([4d7348d](4d7348d)) * tracking plan merged config is cached without its event type ([#7314](#7314)) ([624dd5c](624dd5c)) ### Miscellaneous * setattr/delattr hardening ([#7291](#7291)) ([2855af4](2855af4)) * sync release v1.84.0 to main branch ([#7306](#7306)) ([fa102b7](fa102b7)) * webhook reasons ([#7294](#7294)) ([c298d59](c298d59)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds the loading path for the ClickHouse v2 driver.
ClickhouseV2and its connection scaffolding are already on master; this is the part that gets rows into a table.Loading
load_v2.gokeeps v1's two paths: the S3 copy engine for allowlisted workspaces, otherwise download the load files and stream them in.loadTableFromFilesreads every load file as one stream rather than one file at a time. They are headerless CSV in separate gzip members, so concatenating them and running a single gzip reader over the lot yields one row sequence for the table. Blocks therefore span load files instead of ending early at each one, which keeps the number of inserts — and so the number of parts ClickHouse has to merge — proportional to the rows loaded rather than to the file count.insertBlocksendsWarehouse.clickhouse.v2.commitEveryrows per batch.stmt.ExecContextonly appends to a client-side block and the single wire write happens on commit, socommitEveryis what bounds how much of an upload is held in memory at once."Transaction" is the driver's word here, not ClickHouse's:
BeginTxsends nothing and only health-checks the connection,Commitisbatch.Send, andRollbackdiscards an unsent batch and closes the connection. A block is atomic only until it is sent, so a failure part-way through a load leaves the blocks before it already in the table.Value binding
binder_v2.goconverts each CSV cell into the exact Go type the column needs. Exact types matter because the driver accepts loosely-typed values and then silently corrupts them —int(300)into aUInt8column stores 44,float64(1.9)intoInt64stores 1, neither with an error. A cell that fails to parse resolves tonil, or to the type's typed default when nullable columns are disabled.castStringToArraynever returns a nil slice, which the driver rejects for array columns.sqlquerywrapper:
WithTxhands its context to the callbackWithTxderived a context carryingqueryTimeoutand then calledfn(tx), so every caller shadowed it with the outer context and the timeout was silently inert inside transactions. The callback now receives that context.This is load-bearing for the ClickHouse insert. The only context
batch.Sendcan observe is the one captured on the batch atPrepareContext, so passing the transaction's context there is what allows a deadline to reach the wire write at all —prepareBatchturns it into a socket deadline, andcontextWatchdogcloses the connection if it is cancelled mid-send. (stmt.ExecContext's context is discarded by the driver; that call is an in-memory append.)Postgres now uses the transaction's context in both
WithTxbodies.repo/upload.go's body doesn't reference a context, so it is unchanged in behaviour.s3 credentials no longer reach the query log
loadByCopyCommandpasses the access key and secret to thes3table function as literals, and the v2 middleware was constructed without a secrets regex — sologQuerywrote both at Info once a copy crossedslowQueryThreshold, which a full-table copy does routinely. Now masked, as redshift, snowflake and deltalake already do.Unlike theirs,
s3()takes positional arguments, so there is no label to anchor on: the pattern keeps the load folder and masks the two values that follow it. Reordering the argument list would silently reopen this, sodriver_v2_test.gocovers it.Configuration
Everything is under
Warehouse.clickhouse.v2.*(commitEvery,poolSize,readTimeout,compress,disableNullable,numWorkersDownloadLoadFiles,s3EngineEnabledWorkspaceIDs,slowQueryThreshold,maxLoadDelay,disableLoadTableStats,queryDebugLogs).These do not fall back to the v1 keys, so any destination-level overrides in place today revert to defaults when the flag flips.
disableNullableands3EngineEnabledWorkspaceIDschange behaviour rather than just timing, so it is worth checking what is set before enabling this anywhere.Follow-ups, deliberately not here
write_timeout=1800in the DSN plusexecTimeOutInSeconds/commitTimeOutInSecondsenforced throughmisc.RunWithTimeout. clickhouse-go/v2 has no write-timeout option andsendDatasets no deadline of its own, so the ack half of a commit is bounded byReadTimeout(300s) but the write half is not: a node that stops draining its socket parks a loader indefinitely. This needs its own per-block timeout config —connectTimeoutcannot stand in, since it is alsoDialTimeoutand governs the long-running S3 copy.loadTableFailureRetries. A retry wrapped aroundinsertBlockas it stands would skip rows, because the block is read from the sharedcsv.Readerinside the transaction; a correct one has to buffer the block first, and needs a duplicate story.clickhouse.go) has the same s3 credential logging gap. Left alone as out of scope for this PR.Testing
Unit coverage for the credential masking is in
driver_v2_test.go. Integration coverage for the v2 driver lands infeat.clickhouse-v2-tests, which stacks on this branch.