chDB sources: expose config-declared external data as named views/databases - #2
Open
ShawnChen-Sirius wants to merge 1 commit into
Open
chDB sources: expose config-declared external data as named views/databases#2ShawnChen-Sirius wants to merge 1 commit into
ShawnChen-Sirius wants to merge 1 commit into
Conversation
…abases CHDB_SOURCES declares file/url/s3/postgres/mysql/clickhouse sources in server config; each is materialized at init - while the session is still writable, before the readonly=2 lock - as a named view or a lazily connecting database proxy. Agents query and join them as ordinary tables and discover them through the existing introspection tools. Credentials stay server-side: the engine masks them as [HIDDEN] on every reflective surface (SHOW CREATE, system.tables, system.databases), and the format_display_secrets_in_show_and_select escape stays inert in embedded chDB because the paired server-config switch is never set. file-type sources are checked against CHDB_FILE_ALLOWLIST so the registry cannot become a loophole around the raw-SQL path sandbox, and a database proxy never replaces an existing database of another engine. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Stacked on ClickHouse#202 (P1). Phase 2 of the chDB integration: a config-declared source registry.
What
CHDB_SOURCES(JSON env var) declares external sources —file,url,s3,postgres/mysql(whole-database proxies),clickhouse(remote table) — and the server materializes each one at init as a named view or database, while the session is still writable, before thereadonly=2lock. Agents then query and join them as ordinary tables, with no credentials, placeholders, or connection syntax in their SQL, and discover them through the existinglist_databases/list_tables/describe_tabletools:[{"name": "lake", "type": "s3", "url": "s3://mybucket/events/*.parquet", "access_key_id": "…", "secret_access_key": "…", "format": "Parquet"}, {"name": "appdb", "type": "postgres", "host": "rds.internal", "database": "app", "user": "readonly", "password": "…"}]Security model (each point engine-verified in tests)
[HIDDEN]on every reflective surface an agent can reach (SHOW CREATE,system.tables.create_table_query/as_select,system.databases.engine_full). Theformat_display_secrets_in_show_and_selectescape hatch stays inert in embedded chDB (its paired server-config switch is never set).file-type sources are validated againstCHDB_FILE_ALLOWLIST, so the registry cannot become a loophole around the raw-SQL path sandbox.CHDB_SOURCESdisables chDB loudly with the config error; an individually failing source (unreachable, or an engine not compiled into the build) is logged and skipped so the rest still come up.Tests
25 new tests: pure config parsing/validation, DDL building (quoting, NOSIGN, defaults), and real-engine materialization (masking canary, allowlist refusal, foreign-database guard, proxy idempotence across re-init, fail-soft), plus two end-to-end tests through
_init_chdb_client(sources exist +readonly=2still locked; malformed config disables chDB loudly). Full suite: 95 passed,ruff checkclean.🤖 Generated with Claude Code