feat(clickhouse): add ClickHouse driver with multi-database navigation#501
Open
anglinb wants to merge 1 commit intoouterbase:developfrom
Open
feat(clickhouse): add ClickHouse driver with multi-database navigation#501anglinb wants to merge 1 commit intoouterbase:developfrom
anglinb wants to merge 1 commit intoouterbase:developfrom
Conversation
Adds first-class ClickHouse support to the Studio via a native-fetch HTTP queryable so it works in the browser / Cloudflare Workers / Edge runtime without pulling in @clickhouse/client. Driver core (src/drivers/clickhouse/): - ClickHouseLikeDriver extends CommonSQLImplement, uses backtick-quoted identifiers, maps ClickHouse types (Nullable/LowCardinality wrappers peeled, Array/Map/Tuple/JSON -> text) - schemas() queries system.databases/tables/columns and groups tables by database so every DB the user has access to shows up in the sidebar - updateTableData() emits INSERT, ALTER TABLE...UPDATE WHERE, and ALTER TABLE...DELETE WHERE (ClickHouse has no row-level UPDATE/DELETE) - Flags reflect ClickHouse reality: no triggers, no INSERT RETURNING, no rowid, but supportUseStatement so the UI offers DB switching - ClickHouseHttpQueryable POSTs to /?default_format=JSONCompact&database=X with Basic auth and parses meta[]/data[] into headers/rows plus query statistics Multi-database sidebar switching: - Double-click on a DB emits `USE <name>` (existing sidebar behavior for drivers with supportUseStatement) - ClickHouse HTTP is stateless, so the driver intercepts USE, calls setDatabase() on the HTTP queryable, and returns a synthetic success. Subsequent unqualified queries (e.g. `SELECT * FROM events`) resolve against the selected database via the ?database=X URL param. Registration points: - SupportedDialect / SupportedDriver extended with "clickhouse" - ConnectionTemplateDictionary, createLocalDriver, createOuterbaseDatabaseDriver, workspace baseId page, standard-extension, resource-card utils, and new-resource-list all updated - query-tab's tokenization path gets a shim that maps "clickhouse" -> "mysql" since @outerbase/sdk-transform's SupportedDialect doesn't yet include it (ClickHouse shares MySQL's backtick + comment syntax, close enough for tokenization) Known follow-ups: placeholder icon (not the real ClickHouse brand SVG), async mutation caveat for ALTER TABLE...UPDATE/DELETE, and materialized views aren't surfaced. Co-Authored-By: Claude Opus 4.7 <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.
Summary
Adds first-class ClickHouse support to Outerbase Studio. Works in the browser, Cloudflare Workers, and Edge runtime via native
fetch— no@clickhouse/clientdependency added.src/drivers/clickhouse/):ClickHouseLikeDriverextendsCommonSQLImplement;ClickHouseHttpQueryabletalks to/?default_format=JSONCompact&database=Xwith Basic auth; type mapping peelsNullable(...)/LowCardinality(...)wrappers; flags reflect ClickHouse reality (no triggers, noINSERT RETURNING, no rowid,ALTER TABLE ... UPDATE/DELETEfor mutations).schemas()queriessystem.databases/system.tables/system.columnsso every DB the user can see shows up grouped by database. Double-click switches current DB — the driver interceptsUSE <db>and flips?database=Xon the HTTP queryable (ClickHouse HTTP is stateless, so theUSEalone wouldn't persist), which means subsequent unqualified queries likeSELECT * FROM eventsresolve against the selected DB.SupportedDialect/SupportedDriverextended;ConnectionTemplateDictionary,createLocalDriver,createOuterbaseDatabaseDriver, the workspace base page,standard-extension, resource-card utils, andnew-resource-listall updated. Added a small shim inquery-tab.tsxthat maps"clickhouse" → "mysql"for@outerbase/sdk-transformtokenization (close syntactic match: backticks +--//* */comments).Test plan
npx tsc --noEmit— cleannpm run lint— cleandocker run -p 8123:8123 -e CLICKHOUSE_PASSWORD=... clickhouse/clickhouse-server):analytics,default,logs) with their tablesCREATE TABLE ... ENGINE = MergeTree() ORDER BY idsucceedsINSERT+SELECTround-trip through the HTTP driver (types inferred correctly: UInt64 → numeric, String → text)SELECT * FROM <unqualified_table>works against the newly selected DBKnown follow-ups
ALTER TABLE ... UPDATE/DELETEis async in ClickHouse — UI doesn't currently pollsystem.mutationsDatabaseViewSchemayet🤖 Generated with Claude Code