ClickHouse

Function

DLI has the capability to export data from Flink jobs to the ClickHouse database. However, it only supports exporting data to result tables.

ClickHouse is a column-based database oriented to online analysis and processing. It supports SQL query and provides good query performance. The aggregation analysis and query performance based on large and wide tables is excellent, which is one order of magnitude faster than other analytical databases.

Table 1 Supported types

Type

Description

Supported Table Types

Result table

Prerequisites

Caveats

Syntax

1
2
3
4
5
6
7
8
9
create table clickhouseSink (
  attr_name attr_type 
  (',' attr_name attr_type)* 
)
with (
  'type' = 'clickhouse',
  'url' = '',
  'table-name' = ''
);

Parameter Description

Table 2 Parameters

Parameter

Mandatory

Default Value

Data Type

Description

connector

Yes

None

String

Result table type. Set this parameter to clickhouse.

url

Yes

None

String

ClickHouse URL

It is in the format of jdbc:clickhouse://ClickHouseBalancer instance service IP address 1:ClickHouseBalancer port,ClickHouseBalancer instance service IP address 2:ClickHouseBalancer port/Database name.

  • IP address of a ClickHouseBalancer instance:

    Log in to the MRS console and choose Clusters > Active Clusters in the navigation pane. Click a cluster name, and choose Components > ClickHouse > Instances to obtain the business IP address of the ClickHouseBalancer instance.

  • ClickHouseBalancer port number:

    Log in to the MRS console and choose Clusters > Active Clusters in the navigation pane. Click a cluster name, and choose Components > ClickHouse > Service Configuration. On the Service Configuration page, select ClickHouseBalancer from the All Roles drop-down list. If the MRS cluster does not have Kerberos authentication enabled, search for lb_http_port and set it (defaults to 21425). If Kerberos authentication is enabled, search for lb_https_port and set it (defaults to 21426).

  • The database name is the name of the database created for the ClickHouse cluster. If the database name does not exist, there is no need to specify it.
  • You can configure multiple IP addresses for ClickHouseBalancer instances to avoid single points of failure (SPOFs) of the instances.
  • If the MRS cluster has Kerberos authentication enabled, you also need to add the ssl and sslmode request parameters to the URL, setting ssl to true and sslmode to none. Refer to Example 2 for an example.

table-name

Yes

None

String

ClickHouse table name.

driver

No

ru.yandex.clickhouse.ClickHouseDriver

String

Driver required for connecting to the database. If you do not set this parameter, the automatically extracted driver will be used, which defaults to ru.yandex.clickhouse.ClickHouseDriver.

username

No

None

String

Username for accessing the ClickHouse database. This parameter is mandatory when Kerberos authentication is enabled for the MRS cluster.

password

No

None

String

Password for accessing the ClickHouse database. This parameter is mandatory when Kerberos authentication is enabled for the MRS cluster.

sink.buffer-flush.max-rows

No

100

Integer

Maximum number of rows to be updated when data is written. The default value is 100.

sink.buffer-flush.interval

No

1s

Duration

Interval for data update. The unit can be ms, milli, millisecond/s, sec, second/min, or minute. The default value is 1s. Value 0 indicates that data is not updated.

sink.max-retries

No

3

Integer

Maximum number of retries for writing data to the result table. The default value is 3.

Example