ClickHouse JDBC Catalog
Run catalog SQL with a warehouse SQL user that can manage catalogs and access the source. Ensure network access from the warehouse to metadata, storage, and source endpoints. For connector deployment, host files, JVM settings, or service configuration changes, contact VeloDB Cloud support.
The JDBC Catalog supports connecting to the ClickHouse database via the standard JDBC interface. This document describes how to configure the ClickHouse database connection.
For an overview of the JDBC Catalog, please refer to: JDBC Catalog Overview
Usage notes
To connect to the ClickHouse database, you need
-
ClickHouse version 23.x or higher (versions below this have not been fully tested).
-
The JDBC driver for the ClickHouse database, which you can download from the Maven Repository for the latest or specified version of the ClickHouse JDBC driver. It is recommended to use version 0.4.6 of the ClickHouse JDBC Driver.
-
Network access from the warehouse to the source server, whose default port is 8123.
Connect to ClickHouse
CREATE CATALOG clickhouse PROPERTIES (
'type' = 'jdbc',
'user' = 'username',
'password' = 'pwd',
'jdbc_url' = 'jdbc:clickhouse://example.net:8123/',
'driver_url' = 'clickhouse-jdbc-0.4.6-all.jar',
'driver_class' = 'com.clickhouse.jdbc.ClickHouseDriver'
)
The jdbc_url defines the connection information and parameters to be passed to the ClickHouse JDBC driver. Supported URL parameters can be found in the ClickHouse JDBC Driver Configuration.
Connection security
If you have configured TLS with a globally trusted certificate installed on the data source, you can enable TLS between the cluster and the data source by appending parameters to the JDBC connection string set in the jdbc_url property.
For example, enable TLS by adding the ssl=true parameter to the jdbc_url configuration property:
'jdbc_url' = 'jdbc:clickhouse://example.net:8123/db?ssl=true'
For more information on TLS configuration options, please refer to the Clickhouse JDBC Driver Documentation SSL Configuration Section
Hierarchical mapping
When mapping ClickHouse, a Database in VeloDB Cloud corresponds to a Database in ClickHouse. And a Table under a Database in VeloDB Cloud corresponds to Tables under that Database in ClickHouse. The mapping relationship is as follows:
| VeloDB Cloud | ClickHouse |
|---|---|
| Catalog | ClickHouse Server |
| Database | Database |
| Table | Table |
Column type mapping
| ClickHouse Type | VeloDB Cloud Type | Comment |
|---|---|---|
| bool | boolean | |
| string | string | |
| date/date32 | date | |
| datetime(S)/datetime64(S) | datetime(S) | |
| float32 | float | |
| float64 | double | |
| int8 | tinyint | |
| int16/uint8 | smallint | VeloDB Cloud does not have UNSIGNED data types, so it is scaled up by one magnitude |
| int32/uInt16 | int | Same as above |
| int64/uint32 | bigint | Same as above |
| int128/uint64 | largeint | Same as above |
| int256/uint128/uint256 | string | VeloDB Cloud does not have data types of this magnitude, so it is handled with STRING |
| decimal(P, S) | decimal(P, S) or string | If it exceeds the maximum precision supported by VeloDB Cloud, use string to handle it |
| enum/ipv4/ipv6/uuid | string | |
| array | array | |
| other | UNSUPPORTED |
Related parameters
-
jdbc_clickhouse_query_finalSession variable, default is false. When set to true,
SETTINGS final = 1will be appended to the SQL statements sent to Clickhouse.
Common issues
-
Encountering
NoClassDefFoundError: net/jpountz/lz4/LZ4Factoryerror message when reading Clickhouse dataContact VeloDB Cloud support to check the ClickHouse JDBC driver and provision the matching LZ4 dependency in the managed runtime. Provide the error and driver version. Driver dependencies are installed on warehouse hosts by the service operator.