Skip to content

mountainash-data: Add ClickHouse dialect to IbisBackend #108

@discreteds

Description

@discreteds

Summary

Add ClickHouse as a supported dialect in mountainash-data's IbisBackend, enabling IbisBackend(dialect="clickhouse", ...) connections.

Motivation

While building a PoC connecting mountainash to ClickHouse (via raw ibis.clickhouse.connect()), it became clear that the connection should go through mountainash-data's IbisBackend for consistency with the rest of the framework. ClickHouse is currently not one of the 12 registered dialects.

Scope

Follow the existing data-driven dialect registration pattern:

  1. Settings classClickHouseAuthSettings in core/settings/clickhouse.py with a BackendDescriptor covering:

    • HOST, PORT (default 9000, or 443 for HTTPS/native), DATABASE
    • SECURE (bool, for TLS — common with cloud-hosted ClickHouse)
    • USER, PASSWORD (via PasswordAuth)
  2. Dialect registrationDialectSpec entry in backends/ibis/dialects/_registry.py:

    • ibis_backend_name: "clickhouse"
    • connection_mode: KWARGS
    • connection_string_scheme: "clickhouse://"
    • connection_builder: maps settings to ibis.clickhouse.connect(**kwargs)
  3. Optional dependencyibis-framework[clickhouse] under a [clickhouse] extra in pyproject.toml

  4. Constants — Add CLICKHOUSE to CONST_DB_PROVIDER_TYPE enum

Expected Usage

from mountainash_data import IbisBackend

# Dialect + kwargs
with IbisBackend(dialect="clickhouse", host="sql-clickhouse.clickhouse.com", port=443, user="demo", database="pypi", secure=True) as backend:
    tables = backend.list_tables()
    info = backend.inspect_table("pypi_downloads_per_day")

# URL form
with IbisBackend("clickhouse://demo@sql-clickhouse.clickhouse.com:443/pypi?secure=true") as backend:
    ...

# Settings-driven
params = SettingsParameters.create(
    settings_class=ClickHouseAuthSettings,
    HOST="sql-clickhouse.clickhouse.com",
    PORT=443,
    DATABASE="pypi",
    SECURE=True,
    auth=PasswordAuth(username="demo", password=""),
)
with IbisBackend(params) as backend:
    ...

Notes

  • ibis-framework 12.0.0 supports ClickHouse via ibis.clickhouse.connect() with kwargs: host, port, user, password, database, secure
  • No special DDL hooks needed initially (ClickHouse uses standard SQL for most operations)
  • The existing PostgreSQL and MySQL dialect registrations are good templates to follow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions