Skip to content

Auto-detect ClickHouse Cloud secure connections#541

Merged
auxten merged 1 commit into
mainfrom
fix/clickhouse-cloud-auto-detect-secure
Mar 17, 2026
Merged

Auto-detect ClickHouse Cloud secure connections#541
auxten merged 1 commit into
mainfrom
fix/clickhouse-cloud-auto-detect-secure

Conversation

@auxten

@auxten auxten commented Mar 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Auto-detect .clickhouse.cloud hosts and default to remoteSecure() on port 9440, mirroring clickhouse-client behavior
  • Auto-enable secure=True when port 9440 is specified (mirrors PR #74212)
  • Add ?secure=true support in clickhouse:// URIs
  • Log a warning when rewriting .clickhouse.cloud:9000:9440

Fixes the NO_REMOTE_SHARD_AVAILABLE error users hit when connecting to ClickHouse Cloud without explicitly setting secure=True + port 9440.

Changes

File Change
datastore/adapters.py Add normalize_clickhouse_connection() helper, call it in ClickHouseAdapter.__init__
datastore/core.py Apply normalization when storing _remote_params for ClickHouse sources
datastore/table_functions.py Apply normalization in RemoteTableFunction.to_sql()
datastore/uri_parser.py Support ?secure=true query parameter in clickhouse:// URIs

Test plan

  • 10 new tests in test_remote_connection.py (cloud host, port rewrite, warning log, adapter SQL)
  • 3 new tests in test_table_functions.py (RemoteTableFunction auto-detection)
  • 4 new tests in test_uri_parser.py (?secure=true/1/false, absent)
  • All 300 tests in affected files pass
  • No linter errors

ClickHouse Cloud blocks port 9000 (plaintext native protocol), only
accepting connections on port 9440 (native + TLS). Users connecting
via DataStore hit NO_REMOTE_SHARD_AVAILABLE because the default is
remote() on port 9000.

Mirror the auto-detection logic from clickhouse-client (PRs #56638,
#56649, #74212):
- .clickhouse.cloud hosts -> secure=True + default port 9440
- Port 9440 on any host -> secure=True
- Support ?secure=true in clickhouse:// URIs
@auxten auxten merged commit 1c997dc into main Mar 17, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant