Closed GlockGao closed 1 year ago
@GlockGao
FlinkCDC
(generate new records like UPDATE_BEFORE / UPDATE_AFTER), The flink-connector-clickhouse
cannot generate any new record.replacing merge tree
, refer to: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/replacingmergetree
Flink Version : 1.13.2 Flink CDC version: 2.2 flink-connector-clickhouse version : 1.13-release
The workflow as below: MySQL (8.0.28) -> Flink CDC -> Flink -> ClickHouse.
(1) Configuration : Use local table (engine is MergeTree) for clickhouse sink table, configuration as below: _" 'connector' = 'clickhouse'," + " 'url' = 'clickhouse://clickhouse-server:8123',"+ " 'username' = 'user'"+ " 'password' = 'pass'"+ " 'database-name' = 'database'" + " 'table-name' = 'clickhouse_sinktable'" + " 'sink.batch-size' = '500'" + " 'sink.flush-interval' = '1000'" + " 'sink.max-retries' = '3'" + (2) Relevant Flink Java SQL code: String sql = "INSERT INTO clickhouse_sink_table SELECT vrfi.*, DATE_FORMAT(vrfi.created, 'yyyy-MM') FROM mysql_source_table as vrfi\n"; statementSet.addInsertSql(sql);
The table in MySQL has '539905' rows: select count(id) from sbtest1; +-----------+ | count(id) | +-----------+ | 539905 | +-----------+ 1 row in set (0.05 sec)
Rows for ClickHouse sink table: _SELECT COUNT(id) FROM clickhouse_sink_table;
SELECT COUNT(id) FROM clickhouse_sink_table
Query id: 775dd633-9a8b-4c13-b272-3b317f0575ab
┌─count(id)─┐ │ 556114 │ └───────────┘_
SELECT COUNTDistinct(id) FROM clickhouse_sink_table
Query id: 3e6dc971-47e0-4ca0-836b-eaabf280d2e2
┌─uniqExact(id)─┐ │ 539905 │ └───────────────┘_
Thanks for your help.