chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://clickhouse.com/docs/en/chdb
Apache License 2.0
2k stars 72 forks source link

Is it possible to customize macros/configurations to mimic clustering approach ? #252

Closed LPauzies closed 1 month ago

LPauzies commented 1 month ago

I would want to use in memory clickhouse using chdb to gain performance and easy of use in our CI builds. However I will need to execute a "precomputed" dump of my Clickhouse node that contains some elements from the configuration, for example macros.

I would want to execute at least this kind of query :

CREATE DATABASE test ON CLUSTER '{cluster}' SYNC

Do you know a way to add these "macros" to chdb ? I dont find any documentation on this topic.

Many thanks !

auxten commented 1 month ago

chDB will load config.xml in cwd(current working dir). As chDB is a single node version of ClickHouse engine. Create on cluster is not supported in chDB.

So with config.xml in current dir like:

<clickhouse>  
    <macros>  
        <shard>01</shard>  
        <replica>01</replica>  
        <cluster>cluster_1S_2R</cluster>
    </macros>  
</clickhouse>

and run chDB like:

from chdb import session as chs
sess = chs.Session('dir_you_want_to_keep_your_data')
sess.sql("CREATE DATABASE test ON CLUSTER '{cluster}'")

will got:

ChdbError: Code: 701. DB::Exception: Requested cluster 'cluster_1S_2R' not found. (CLUSTER_DOESNT_EXIST)

Hope this could help you.