Skip to main content

ClickHouse

To add a ClickHouse connection, click on the ClickHouse option in Connect a data source section. connect

Required Permissions

Minimum Permissions Required

To ensure full compatibility and stability, the ClickHouse user account used by Wren AI requires the following permissions on your target database:

  • SELECT on tables and views
  • CREATE VIEW
  • DROP VIEW

Wren AI automatically creates and drops temporary views during query execution to support advanced analytics and modeling features.
The views generated by Wren AI will always use unique, system-generated names and will not conflict with or overwrite your existing views.

If your user account is missing any of these permissions, you may encounter errors such as “insufficient privilege” or failures when creating or dropping views.

To grant the necessary permissions, please execute the following SQL statements in your ClickHouse environment, replacing <your-clickhouse-database> with your actual database name and wren with the appropriate user:

GRANT SELECT ON <your-clickhouse-database>.* TO wren;
GRANT CREATE VIEW ON <your-clickhouse-database>.* TO wren;
GRANT DROP VIEW ON <your-clickhouse-database>.* TO wren;

Connect

Fill in the connection settings: clickhouse

Connecting from a local ClickHouse

For MacOS and Windows users connecting from a local ClickHouse, simply use host.docker.internal as the host to establish the connection.

You can refer to this blog post, which includes detailed steps for your reference.

Display name

The display name for the database in the Wren AI interface.

Host

IP address or domain name of your ClickHouse database.

Port

Your ClickHouse database port.

Username

The database username for the account that you want to use to connect to your ClickHouse database.

Password

The password for the username that you use to connect to the database.

Database name

The name of the database you want to connect to.

Use SSL

Enable SSL for the connection. If you are using username and password authentication, you must enable SSL.

Click Next to start connection and go to the next step.

Select Tables

All tables of your connected ClickHouse dataset will be listed in this step. Select which tables you want to use in Wren AI. Each selected table will be created as a data model. See the Modeling documentations to learn more about what is data models. select_table

Define relationships

Define the relationships among selected tables in this step. If you have defined primary keys and foreign keys in your ClickHouse dataset, we will list suggested relationships based on the information. If not, you can also add relationships by clicking the Add relationships button on the table blocks. relationship

Define following properties in a relationship:

  • From: Select the left side table and column of this relationship.
  • To: Select the right side table and column of this relationship.
  • Relationship Type: Select the type of relationship. add_relationship

Find more information about relationship in Modeling - Working with Relationships

You can also skip this step and finish connection.