开发者社区> 问答> 正文

DDL中声明主键会报类型不匹配怎么解决?

Hi: flink版本1.11.0 connector为kafka DDL中声明某个字段为primary key时,会报类型不匹配,去掉primary key constraint就可以正常执行。 把shop_id设置为 varchar not null也不行。

org.apache.flink.table.api.ValidationException: Type STRING NOT NULL of table field 'shop_id' does not match with the physical type STRING of the 'shop_id' field of the TableSource return type.

SQL如下: create table source_0 ( shop_id varchar, user_id bigint, category_id int, ts bigint, proc_time as PROCTIME(), event_time AS TO_TIMESTAMP(FROM_UNIXTIME(ts / 1000, 'yyyy-MM-dd HH:mm:ss')), watermark for event_time AS event_time, PRIMARY KEY (shop_id, user_id) NOT ENFORCED ) with ( 'connector.type' = 'kafka',

) *来自志愿者整理的flink邮件归档

展开
收起
游客sadna6pkvqnz6 2021-12-07 16:58:22 719 0
1 条回答
写回答
取消 提交回答
  • 是的 加了 primary key constraint 后会强制将类型转成 Not nullable,这个是 primary key 的特性导致的。*来自志愿者整理的flink

    2021-12-07 20:22:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Phoenix 全局索引原理与实践 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载