当前位置:   article > 正文

【flink报错】flink cdc无主键时的操作_scan.incremental.snapshot.chunk.key-column

scan.incremental.snapshot.chunk.key-column

文章目录

一. 报错

“org.apache.flink.table.api.validationexception: ‘scan.incremental.snapshot.chunk.key-column’ must be set when the table doesn’t have primary keys”

报错提示当表没有主键时,必须设置 ‘scan.incremental.snapshot.chunk.key-column’。

这里表没有主键,不是flink table中设置的primary key,而是物理表中没有主键。

二. 解决

如上述报错提示:在创建表的时候,为没有主键的表指定一个唯一的标识列作为’scan.incremental.snapshot.chunk.key-column’。如下

为MY_TABLE表指定了id列作为’scan.incremental.snapshot.chunk.key-column’。这样就可以解决没有主键的表无法进行增量捕获的问题。



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'
);


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/795357
推荐阅读
相关标签
  

闽ICP备14008679号