Skip to content

ClickHouse API Reference

metaxy.metadata_store.clickhouse.ClickHouseMetadataStore

ClickHouseMetadataStore(connection_string: str | None = None, *, connection_params: dict[str, Any] | None = None, fallback_stores: list[MetadataStore] | None = None, **kwargs: Any)

Bases: IbisMetadataStore

ClickHouse metadata storeusing Ibis backend.

Connection Parameters
store = ClickHouseMetadataStore(
    backend="clickhouse",
    connection_params={
        "host": "localhost",
        "port": 9000,
        "database": "default",
        "user": "default",
        "password": ""
    },
    hash_algorithm=HashAlgorithm.XXHASH64
)

Parameters:

  • connection_string (str | None, default: None ) –

    ClickHouse connection string.

    Format: clickhouse://[user[:password]@]host[:port]/database[?param=value]

    Examples:

    - "clickhouse://localhost:9000/default"
    - "clickhouse://user:pass@host:9000/db"
    - "clickhouse://host:9000/db?secure=true"
    

  • connection_params (dict[str, Any] | None, default: None ) –

    Alternative to connection_string, specify params as dict:

    • host: Server host

    • port: Server port (default: 9000)

    • database: Database name

    • user: Username

    • password: Password

    • secure: Use secure connection (default: False)

  • fallback_stores (list[MetadataStore] | None, default: None ) –

    Ordered list of read-only fallback stores.

  • **kwargs (Any, default: {} ) –

Raises:

  • ImportError

    If ibis-clickhouse not installed

  • ValueError

    If neither connection_string nor connection_params provided

Source code in src/metaxy/metadata_store/clickhouse.py
def __init__(
    self,
    connection_string: str | None = None,
    *,
    connection_params: dict[str, Any] | None = None,
    fallback_stores: list["MetadataStore"] | None = None,
    **kwargs: Any,
):
    """
    Initialize [ClickHouse](https://clickhouse.com/) metadata store.

    Args:
        connection_string: ClickHouse connection string.

            Format: `clickhouse://[user[:password]@]host[:port]/database[?param=value]`

            Examples:
                ```
                - "clickhouse://localhost:9000/default"
                - "clickhouse://user:pass@host:9000/db"
                - "clickhouse://host:9000/db?secure=true"
                ```

        connection_params: Alternative to connection_string, specify params as dict:

            - host: Server host

            - port: Server port (default: `9000`)

            - database: Database name

            - user: Username

            - password: Password

            - secure: Use secure connection (default: `False`)

        fallback_stores: Ordered list of read-only fallback stores.

        **kwargs: Passed to [metaxy.metadata_store.ibis.IbisMetadataStore][]`

    Raises:
        ImportError: If ibis-clickhouse not installed
        ValueError: If neither connection_string nor connection_params provided
    """
    if connection_string is None and connection_params is None:
        raise ValueError(
            "Must provide either connection_string or connection_params. "
            "Example: connection_string='clickhouse://localhost:9000/default'"
        )

    # Initialize Ibis store with ClickHouse backend
    super().__init__(
        connection_string=connection_string,
        backend="clickhouse" if connection_string is None else None,
        connection_params=connection_params,
        fallback_stores=fallback_stores,
        **kwargs,
    )

Functions

metaxy.metadata_store.clickhouse.ClickHouseMetadataStore.config_model classmethod

config_model() -> type[ClickHouseMetadataStoreConfig]

Return the configuration model class for this store type.

Subclasses must override this to return their specific config class.

Returns:

Note

Subclasses override this with a more specific return type. Type checkers may show a warning about incompatible override, but this is intentional - each store returns its own config type.

Source code in src/metaxy/metadata_store/clickhouse.py
@classmethod
def config_model(cls) -> type[ClickHouseMetadataStoreConfig]:  # pyright: ignore[reportIncompatibleMethodOverride]
    return ClickHouseMetadataStoreConfig