First time creating a connector? Read this first.
Requirements
You will need:-
A ClickHouse server that Unstructured can reach over ClickHouse’s HTTP or HTTPS interface. The connector does not use the native TCP protocol. The connector supports two kinds of deployment:
- ClickHouse Cloud: Use your service’s hostname and port
8443. Connections to ClickHouse Cloud always use TLS. - Self-managed ClickHouse (on-premises or in your own cloud account): Use your server’s hostname, plus port
8123for plain HTTP or port8443for HTTPS. If a private certificate authority (CA) signed your server’s TLS certificate, you also need that CA’s certificate as PEM text.
Timed out connecting to ClickHouse. Check the host, port, TLS setting and firewall rules. - ClickHouse Cloud: Use your service’s hostname and port
- The ClickHouse user’s name and password. If the user has no password, the password can be empty.
- The name of the database that contains the table. Database and table names cannot contain a backtick, single quote, or backslash.
-
The name of the table to read.
The user needs the
SELECTprivilege on the table: -
A table with key columns that identify each row.
By default, the connector uses the table’s sorting key (the
ORDER BYclause) as the key columns. The sorting key must consist of plain, non-nullable scalar columns, not expressions. If the table has no usable sorting key, you can name the key columns in the connector’s settings instead. The connector reads the table in key order and groups the keys into batches. Each batch is one record, and the connector stores each row of a batch as its own JSON file. The key columns must identify one row. If more than one row has the same key values, the run fails withMore than one row has the same value for the key columns (<key columns>). Set the key columns to columns that identify one row.ClickHouse does not require a sorting key to be unique, so the default key columns can fail on a plainMergeTreetable. Set Key columns (key_columns) to a unique column or a combination such as(tenant, id). The connection test does not check the table for equal key values. The run checks them as it reads. For tables that use theReplacingMergeTree,CollapsingMergeTree, orVersionedCollapsingMergeTreeengine families (including theReplicatedandSharedvariants), the connector reads withFINAL.FINALapplies the engine’s merge rules. ForReplacingMergeTree, it returns the latest version of each row. The Collapsing engines drop cancelled rows, so the connector does not read a key whose rows cancel out. If the key columns are exactly the sorting key of such a table, rows with equal key values are versions of one row, and the run does not fail. The connector does not useFINALfor other engines, such asSummingMergeTreeandAggregatingMergeTree. The connector builds each query from bound parameters. It does not support a free-formWHEREfilter, so it reads the whole table. Column names cannot contain a backtick, single quote, or backslash. Incremental sync is not available. Every run reads the whole table, so the Version column (version_column) and Incremental overlap (s) (overlap_seconds) settings do not change which rows the connector reads.
Examples
To create a ClickHouse source connector, see the following examples for ClickHouse Cloud and for a self-managed server. For more information on working with source connectors using the Unstructured API, see Source endpoints. Delete any optional setting that you do not need, and replace the angle-bracket placeholders in the settings you keep. If you leave a placeholder inversion_column, key_columns, or columns, the connection test fails.
- ClickHouse Cloud
- Self-managed
8123. For HTTPS, set port to 8443 and secure to true. If a private CA signed the server’s certificate, also set ca_cert to the CA certificate’s PEM text.
Configuration settings
Replace the preceding placeholders as follows:The ClickHouse server’s hostname or IP address, without a scheme or path. For ClickHouse Cloud, this is the service’s hostname.
The HTTP(S) interface port. Use
8443 for ClickHouse Cloud and for self-managed servers with TLS, or 8123 for a self-managed server without TLS.True to connect over HTTPS, or false to connect over plain HTTP. The default is
true. Keep this true for ClickHouse Cloud. For a self-managed server on port 8123, set it to false.The user’s password. If the user has no password, set this to an empty string and confirm that the connection test passes.
True to verify the server’s certificate, or false to skip verification. The default is
true. Set this to false only for testing.The PEM text of a private CA certificate that signed the server’s certificate. The text must contain
-----BEGIN CERTIFICATE-----. In a JSON request body, write each line break in the PEM text as \n, for example "-----BEGIN CERTIFICATE-----\n<certificate-text>\n-----END CERTIFICATE-----". Omit it if a public CA signed the certificate.The number of seconds to wait to open a connection. A paused ClickHouse Cloud service must wake up first, so raise this value if the first connection after a long idle period times out.
The columns that identify a row, in the order the connector pages through the table. No two rows can have the same values, or the run fails. By default, the connector uses the table’s sorting key, which must consist of plain columns. ClickHouse does not require a sorting key to be unique. Set this field unless the table uses a
Replacing, Collapsing, or VersionedCollapsing MergeTree engine keyed by its sorting key.A
Date or DateTime column that changes when a row changes. Incremental sync is not available. Every run reads the whole table, so this setting does not change which rows the connector reads. The connector still checks that the column exists and is a Date or DateTime column.The number of rows that the connector fetches in one download step and holds in memory at once. The default is
500 and the maximum is 1000. The limit applies to rows, not bytes, so lower it for wide rows or large columns.The number of seconds to re-read when syncing incrementally. Incremental sync is not available, so this setting has no effect.
Troubleshooting
ClickHouse rejected the username or password
ClickHouse rejected the username or password
Issue: The connection test fails with
ClickHouse rejected the username or password.Cause: The username or password does not match a ClickHouse user.Solution: Check the Username (username) and Password (password) values. If the user has no password, test with an empty Password and confirm the connection test passes.Timed out connecting to ClickHouse
Timed out connecting to ClickHouse
Issue: The connection test fails with
Timed out connecting to ClickHouse. Check the host, port, TLS setting and firewall rules.Cause: Unstructured could not open a connection to the host and port before the connect timeout expired. Possible causes:- A firewall or IP access list blocks the connection.
- The port or TLS setting does not match the server.
- A paused ClickHouse Cloud service did not wake up in time.
port) and Use TLS (secure) match your deployment (8443 with TLS, or 8123 without). Allow connections from Unstructured through any firewall or IP access list.
For ClickHouse Cloud, raise Connect timeout (s) (connect_timeout) if the first connection after a long idle period fails.Could not reach the provider
Could not reach the provider
Issue: The connection test fails with
Could not reach the provider. Check network egress, DNS, and firewall rules.Cause: The hostname does not resolve, or the host is unreachable from Unstructured.Solution: Check that Host (host) is correct, is a bare hostname, and is reachable from Unstructured.The ClickHouse settings are not valid
The ClickHouse settings are not valid
Issue: The connector fails with
The ClickHouse settings are not valid. followed by the field path and reason, for example connector_config.host: Value error, host must be a bare hostname or IP address or connector_config.ca_cert: Value error, ca_cert must be PEM text.Cause: A connection field value does not meet the connector’s validation rules.Solution: Enter only the hostname in Host (host), with no scheme (https://), path, or credentials. Paste the full PEM text, including the -----BEGIN CERTIFICATE----- line, in CA certificate (ca_cert).Batch size is above the limit
Batch size is above the limit
Issue: The connector fails with
The ClickHouse settings are not valid. followed by indexer_config.batch_size: Value error, batch_size must be at most 1000. and a longer explanation.Cause: Rows per batch (batch_size) is above the limit of 1000 rows.Solution: Set Rows per batch (batch_size) to 1000 or less.ClickHouse denied the operation
ClickHouse denied the operation
Issue: The connector fails with
ClickHouse denied the operation. Check the user's grants on the database and table.Cause: The user lacks the SELECT privilege that reading the table needs.Solution: Grant SELECT on the table.ClickHouse could not find the database, table or column
ClickHouse could not find the database, table or column
Issue: The connector fails with
ClickHouse could not find the database, table or column. Check the names in the settings. or The ClickHouse table was not found, or the user cannot read it.Cause: A database, table, or column name is wrong, or the user cannot read the table.Solution: Check the Database (database), Table (table), Key columns (key_columns), and Version column (version_column) values. Confirm that the user has SELECT on the table.None of the requested rows were found
None of the requested rows were found
Issue: A download fails with
None of the requested rows were found in ClickHouse.Cause: None of the rows that the run requested exist in the table when the download reads it.Solution: Check that the rows still exist in the table, and then run the workflow again.The source table has no usable key
The source table has no usable key
Issue: The connector fails with one of the following messages:
The table has no sorting key. Set the key columns in the settings.The table's sorting key contains an expression. Set the key columns in the settings.Key column '<name>' is nullable; key columns must not be nullable.Key column '<name>' must be a plain scalar type.The key columns contain a duplicate.Key column '<name>' does not exist or cannot be read.
key_columns) to plain, non-nullable columns that identify each row.More than one row has the same key values
More than one row has the same key values
Issue: The connector fails with
More than one row has the same value for the key columns (<key columns>). Set the key columns to columns that identify one row.Cause: The key columns do not identify one row. By default, the key columns are the table’s sorting key, and ClickHouse does not require a sorting key to be unique. The connector accepts equal key values only when the table uses a ReplacingMergeTree, CollapsingMergeTree, or VersionedCollapsingMergeTree engine and the key columns are exactly its sorting key.Solution: Set Key columns (key_columns) to a column or combination of columns that has a different value in every row, such as (tenant, id).The version column is rejected
The version column is rejected
Issue: The connector fails with
Version column '<name>' does not exist or cannot be read. or The version column must be a Date or DateTime column.Cause: The column does not exist, the user cannot read it, or it is not a Date or DateTime column.Solution: Set Version column (version_column) to a Date or DateTime column that the user can read, or leave it empty.
