Repository navigation
fix(clickhouse): use the upstream clickhouse-go driver - #615
Conversation
The ClickHouse driver imported a fork of clickhouse-go that differs from upstream v2.48.0 only in the database/sql driver name. Nothing opens a connection by that name, so the fork adds upkeep and no behaviour. Consumers that also use upstream link both copies. Import github.com/ClickHouse/clickhouse-go/v2 v2.49.0 instead. v2.49.0 changes two things the tests can see: - A Named string parameter is escaped by the driver. A caller must not escape it first. TestCP22_GoBindsTabString asserts the new behaviour. - With LZ4 on, every HTTP request also sends network_compression_method=LZ4, the server default. To verify: go test ./sqlconnect/internal/clickhouse/... ./sqlconnect/clickhousequery/... and check that go mod graph shows no rudderlabs/clickhouse-go. Co-Authored-By: Claude Fable 5.2 <[email protected]> 🔒 Scanned for secrets using gitleaks 8.30.1
clickhouse-go v2.49.0 sends network_compression_method with every query, the hello included. A profile that pins another value refuses the open. The probe that names the refused setting then blamed additional_result_filter, because every probe carries the new setting. Probe first with an empty settings map and no deadline. A refusal there comes from the setting clickhouse-go adds, so validation names it. To verify: go test -run TestSQ14_ReadonlyAndConstraints ./sqlconnect/internal/clickhouse/ Co-Authored-By: Claude Fable 5.2 <[email protected]> 🔒 Scanned for secrets using gitleaks 8.30.1
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
=======================================
Coverage 90.73% 90.73%
=======================================
Files 179 179
Lines 8861 8863 +2
=======================================
+ Hits 8040 8042 +2
Misses 819 819
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Note: this review is part of an experiment, the #proj-auto-approve auto-approval process. No human looked at this PR. Auto-approve category: refactors with no product behavior change.
Approved. The ClickHouse driver now imports upstream github.com/ClickHouse/clickhouse-go/v2 v2.49.0 instead of the fork at v2.48.0, and validation names network_compression_method when a profile refuses it at connection open.
What I checked:
- The fork's
v2.48.0tag (0fd682b) is 4 commits ahead of upstreamv2.48.0(69b5195) and 0 behind. Outside examples, benchmarks, tests, docs and CI, its only library change besides the module path isclickhouse_std.go:sql.Register("clickhouse-v2", ...)in place of"clickhouse". A code search finds noclickhouse-v2in this repository, so nothing here opens a connection by that driver name. go.moddrops the fork and requires upstream v2.49.0. Themoby/mobymoves are indirect.- The second commit makes
refusedOpenSettingtry an empty settings map first. clickhouse-go still addsnetwork_compression_methodto the hello, so a refusal there names that setting, andTestSQ14_ReadonlyAndConstraintspins it with aZSTDconstraint (server code 452, stage 1). - The description lists the v2.49.0 behaviour changes that reach this driver, and says the ClickHouse Cloud tests did not run.
- test, verify and zizmor pass.
[nit] The release notes for the next sqlconnect-go version should say that a program which imports both this library and the fork must swap its own imports, because the two modules have separate context keys and error types. The description says it; the changelog is where consumers will look.
To help the FYI next time:
- Record the agreed migration plan on the tracking ticket, so the people who decided it show up there.
|
On the release-notes nit: agreed. release-please writes the changelog from the PR title, so I add the import-swap note to the GitHub release of the version that ships this change. The consumer that imports both modules swaps its imports in the same PR that takes the release. |
Description
What changed
The ClickHouse driver imports
github.com/ClickHouse/clickhouse-go/v2v2.49.0. Before, it imported our fork of clickhouse-go at v2.48.0.go.modrequires upstream v2.49.0 directly and drops the fork.moby/moby/apiandmoby/moby/clientmove because v2.49.0 requires them. They are test-only.network_compression_methodwhen a profile refuses it at connection open (second commit)..agents/knowledgename the upstream driver and point at v2.49.0 source files.Why
The fork equals upstream v2.48.0 except for one line: it registers the
database/sqldriver asclickhouse-v2. This library never opens a connection by driver name, so the fork adds no behaviour. It does add upkeep, and a program that also uses upstream links both copies.Behaviour that changes with v2.49.0
Every upstream hunk between v2.48.0 and v2.49.0 was checked against how this driver uses clickhouse-go. Most of the release touches the native protocol, batch inserts and DSN parsing, which this driver does not use. These changes reach us:
network_compression_method=LZ4, the hello included. That is the server default, so areadonly=1profile accepts it. A profile that pins another value now refuses the connection. Before the second commit, validation blamedadditional_result_filterfor that refusal. Now it namesnetwork_compression_method.TestSQ14_ReadonlyAndConstraintscovers it.TestCP22_GoBindsTabStringasserts the new behaviour. Nothing in this library usesNamed.\0. Before, it went out as a raw byte.Mapwhose key type contains a comma now decodes. For exampleMap(DateTime64(3, 'UTC'), String). The read still fails, because the mapper does not supportMap, but withCH_TYPE_UNSUPPORTEDin place ofCH_UNKNOWN.clickhouse-go/2.49.0.Unchanged: the deadline handling (
queryOptions), the response drain (discardAndClose), the HTTP health check, and whatRow()returns for every column type the mapper reads.How to verify
go test -count=1 ./sqlconnect/internal/clickhouse/... ./sqlconnect/clickhousequery/...passes (needs Docker).go mod graph | grep rudderlabs/clickhouse-goprints nothing.Not covered
clickhouse_cloudbuild tag) did not run. CI does not run them either. The default value ofnetwork_compression_methodon ClickHouse Cloud is not checked.network_compression_methodcase runs on server 26.3 with aCONSTconstraint only.Linear Ticket
https://linear.app/rudderstack/issue/SEC-995
Security
🤖 Generated with Claude Code
BEGIN_COMMIT_OVERRIDE
fix(clickhouse): use the upstream clickhouse-go driver (#615)
END_COMMIT_OVERRIDE