feat(clickhouse): add cloud_mode connection option - #6037
Open
cookieark7 wants to merge 1 commit into
Open
Conversation
Signed-off-by: cookieark <aishwary.kantode@gmail.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
Closes #5785.
Cloud mode could only be turned on by having
clickhouse.cloudin the host name. Self-hosted deployments using the replicated database engine have the same constraint — no single-stepCREATE TABLE ... AS SELECT— but no way to enable the mode, so the workaround in the issue was adding a CNAME to make the host resolve asclickhouse.cloud.my.domain.net.This adds a
cloud_modeconnection option. It is a tri-state: unset (the default) keeps the existing host-name detection,trueforces cloud mode on,falseforces it off. Existing configurations are unaffected since nothing sets it.The
cloud_modeproperty had to be renamed to_resolved_cloud_mode— a Pydantic field and a property of the same name silently return the property object rather than the field value, which is truthy, so keeping both would have flipped every existing standalone user into cloud mode.Test Plan
test_clickhouse_cloud_modeintests/core/test_connection_config.py. The assertions go through_extra_engine_configand the adapter'sengine_run_moderather than reading the field back, since what matters is that the value reaches the adapter and selects the two-step CTAS.I checked the tests actually fail against broken implementations rather than just passing against this one. Five mutations, all caught: ignoring the explicit setting, dropping the host-name fallback, removing
cloud_modefrom theinsert_quorumgate, breaking the config-to-adapter wiring, and inverting the value. An earlier version of the tests missed the third one, because the case I had written also setcluster, which satisfies that gate on its own — added a cloud-mode-without-cluster case to cover it.Also verified against a local ClickHouse that setting
cloud_mode: trueon a plain host changes the emitted SQL from a singleCREATE ... AS SELECTtoCREATE ... EMPTY AS SELECTplusINSERT, and that the rows still land.Locally:
make clickhouse-test168 passed,make fast-test2622 passed,make styleclean.I don't have a replicated-database deployment, so the end-to-end benefit for that setup is unverified — @cams-data if you're still on the CNAME workaround, this would be worth a check.
Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO🤖 Generated with Claude Code