一. 報(bào)錯
“org.apache.flink.table.api.validationexception: ‘scan.incremental.snapshot.chunk.key-column’ must be set when the table doesn’t have primary keys”
報(bào)錯提示當(dāng)表沒有主鍵時(shí),必須設(shè)置 ‘scan.incremental.snapshot.chunk.key-column’。
這里表沒有主鍵,不是flink table中設(shè)置的primary key,而是物理表中沒有主鍵。
二. 解決
如上述報(bào)錯提示:在創(chuàng)建表的時(shí)候,為沒有主鍵的表指定一個(gè)唯一的標(biāo)識列作為’scan.incremental.snapshot.chunk.key-column’。如下文章來源:http://www.zghlxwxcb.cn/news/detail-856139.html
為MY_TABLE表指定了id列作為’scan.incremental.snapshot.chunk.key-column’。這樣就可以解決沒有主鍵的表無法進(jìn)行增量捕獲的問題。文章來源地址http://www.zghlxwxcb.cn/news/detail-856139.html
CREATE TABLE IF NOT EXISTS my_table (
id BIGINT,
name STRING,
age INT,
PRIMARY KEY (id) NOT ENFORCED
) WITH (
'connector' = 'mysql-cdc',
'hostname' = 'xxx',
'port' = '1521',
'username' = 'conn_uat',
'password' = 'xxxx',
'database-name' = 'CONN_UAT',
'schema-name' = 'strc',
'table-name' = 'MY_TABLE',
'scan.incremental.snapshot.chunk.key-column' = 'id'
);
到了這里,關(guān)于【flink報(bào)錯】flink cdc無主鍵時(shí)的操作的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!