Repository navigation
feat(warehouse): enable the clickhouse v2 driver behind a flag - #7311
Merged
Merged
Conversation
achettyiitr
force-pushed
the
feat.clickhouse-v2-tests
branch
from
August 25, 2026 18:40
cfe29f8 to
dfb6b3f
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7311 +/- ##
==========================================
+ Coverage 79.45% 79.78% +0.32%
==========================================
Files 611 611
Lines 68289 68325 +36
==========================================
+ Hits 54258 54511 +253
+ Misses 10846 10598 -248
- Partials 3185 3216 +31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
saikumarrs
approved these changes
Aug 27, 2026
saikumarrs
reviewed
Aug 27, 2026
achettyiitr
force-pushed
the
feat.clickhouse-v2-tests
branch
3 times, most recently
from
August 28, 2026 08:41
64e25f8 to
51c4065
Compare
saikumarrs
approved these changes
Aug 28, 2026
ItsSudip
approved these changes
Aug 28, 2026
Wires Warehouse.clickhouse.useV2Driver into the integrations manager and covers both implementations: TestIntegration runs the existing suite against v1 and TestIntegrationV2 runs the same suite against v2, so coverage cannot drift. TestSecureConnection adds the TLS path, generating its certificate per run and starting the server with dockertest. The flag defaults to false, so the rollout unit is a deployment.
…mentation
Every connection in the suite came from sql.Open("clickhouse", ...),
registered by github.com/ClickHouse/clickhouse-go. The suite runs twice,
so the v2 pass was being verified through a v1 handle.
That is not only inelegant, it hides things. v1 cannot represent every
type v2 can create, and a read often survives anyway because the query
coerces the column to String, so only a write surfaces the gap.
Connections now go through one connectDB closure that picks the driver
from useV2, which also removes the DSN string duplicated at seven call
sites, and the cluster helper takes the same closure so its DDL runs over
the driver under test too.
The two implementations are selected by CLICKHOUSE_USE_V2 rather than by
separate test functions, and the warehouse matrix carries a clickhouse-v2
leg that sets it, so each gets its own job. Unset means v1, so a bare
go test in the package keeps working.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
Every subtest carried a " - <bool> driver" suffix so the two runs could be told apart in one log. They are separate jobs now, so the suffix only made the names harder to read and to match with -run. The implementation is logged once at the start instead. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
The suite set RSERVER_WAREHOUSE_CLICKHOUSE_USEV2DRIVER, but ConfigKeyToEnv turns Warehouse.clickhouse.useV2Driver into RSERVER_WAREHOUSE_CLICKHOUSE_USE_V2_DRIVER: an underscore before each capital that follows a lowercase or a digit. The two never matched, so the flag stayed false and the embedded server ran v1 even in the v2 run. The CI log shows it, creating tables from clickhouse/clickhouse.go. Derive the name from the key instead of spelling it out, so it cannot drift again. Also leaves the slow query threshold as the literal it was. envKey produced exactly the same string for v1, so routing it through the helper only added diff, and envKey has no other callers. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
RetrieveRecordsFromWarehouse stringifies each scanned value, formatting time.Time as RFC3339. clickhouse-go v2 scans a DateTime into *time.Time where v1 handed back a value, so it missed that case, fell through to cast.ToString and produced Go's own layout: want 2023-05-12T04:26:48Z got 2023-05-12 04:26:48 +0000 UTC Every other column in the row matched, so the pointer datetime is the only value reaching the default branch. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
The v2 cluster compose pinned clickhouse-server 25.8 while mounting the node configs written for 21.x over the whole of /etc/clickhouse-server. Every ClickHouse container failed to start - none reached Healthy, and compose aborted on the first exit, clickhouse04 (232). The single node v2 compose mounts no config at all, which is why only the cluster broke. The newer server is only needed for native JSON, which the cluster test does not use. The driver does not require it either: MinSupportedVersion just logs "unsupported clickhouse version" and connects anyway (conn.go:110). So the cluster stays on the server its configs were written for, and the v2 compose is gone. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
The cluster test asserts the recreate fails with REPLICA_IS_ALREADY_EXIST by pulling the code off *clickhouse-go.Exception. That is v1's type; v2 raises its own, so ErrorAs found nothing: expected: *clickhouse.Exception in chain: "code: 253 ... (REPLICA_IS_ALREADY_EXIST)" (*proto.Exception) Read the code through a helper that accepts either, and fail if the error is neither, so the type check is kept rather than traded for a string match. initializeClickhouseClusterMode has no useV2 to branch on. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
The v2 loader concatenates the load files into one gzip stream, so a block ends after commitEvery rows rather than at a file boundary. Three files of 16 rows committed every 5 puts a commit inside every file and a block across every boundary. v1 runs the same case as a control: it commits once at the end and has to produce the same rows. Each copy of the fixture gets its own ids. The load table is a ReplacingMergeTree ordered by (received_at, id), so identical rows could be collapsed by a background merge and the count would be racy. uniqExact is what shows every row landed exactly once — a block sent twice would still be counted by RowsInserted, but cannot invent new ids. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
useV2Driver resolved once at construction, so the rollout unit was a deployment. The factories only receive a destination type, so instead of threading a warehouse through every one of them, the clickhouse case now returns a selector that holds both implementations and picks when a warehouse actually arrives. Every interface method carrying a model.Warehouse selects before delegating; the rest reach the chosen one through the embedded field. Setup is not enough on its own: the warehouse admin query path calls Connect on a manager it never sets up, and would have stayed on v1. The config keys are ordered most specific first and GetBoolVar takes the first that is set, so a destination can be switched on ahead of its workspace and — the case a rollout depends on — switched back off after the global flag is on. An allowlist could only ever add. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
achettyiitr
force-pushed
the
feat.clickhouse-v2-tests
branch
from
August 28, 2026 10:41
36b2ea4 to
4997dbe
Compare
go.mod is on go 1.26, whose `go fix` rewrites a three-clause loop over an int bound into a range. make fmt runs `go fix ./...` and verify checks the tree is unchanged afterwards, so leaving these in the classic form fails that job. Behaviour is identical: every bound here is constant across the loop. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4 🔒 Scanned for secrets using gitleaks 8.29.1
achettyiitr
force-pushed
the
feat.clickhouse-v2-tests
branch
from
August 28, 2026 10:49
4997dbe to
c163224
Compare
testdata/load.csv.gz reuses just two ids across its sixteen rows. The load table is a ReplacingMergeTree ordered by (received_at, id), so the 48 rows loaded from three copies collapsed to one per distinct sort key and the count came back as 6 rather than 48. Suffixing per copy was not enough: it only made the two ids distinct between copies, which is where the 3 x 2 came from. Every row now gets a unique id, so nothing shares a sort key and both the row count and uniqExact(id) are exact rather than merge-dependent. The expected count now comes from the rows actually written rather than a hardcoded 16, so it follows the fixture if that ever changes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014pXCMMrSLnt63xCWqvXhQ4
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.
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 — review that one first.
The flag
manager.goresolves ClickHouse through a smallnewClickhousehelper. WithWarehouse.clickhouse.useV2Driverunset — the default — nothing changes: it returnsclickhouse.Newexactly 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 aclickhouse-v2leg that sets it, so each gets its own job, its own log and its own re-run. Unset means v1, so a barego test ./warehouse/integrations/clickhouse/...keeps working.Verification connects with the driver under test
Previously every connection came from
sql.Open("clickhouse", …), registered bygithub.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
connectDBclosure that picks the driver from the implementation under test. That also removes the DSN string which was duplicated at seven call sites, andinitializeClickhouseClusterModetakes 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 intot.TempDir()rather than committed, following the pattern inwarehouse/integrations/tunnelling/connect_test.go. It uses dockertest rather than testcompose so the existing suite is left alone.docker-compose.clickhouse-v2.ymlanddocker-compose.clickhouse-cluster-v2.yml— v2 runs against ClickHouse 25.8, where v1 runs against 21.Linear Ticket
Security