Re: DDL中声明主键会报类型不匹配
你可以试用下 新版的 connector ('connector' = 'kafka'),对于类型的处理要完善很多。 Best, Jark On Wed, 26 Aug 2020 at 20:46, Danny Chan wrote: > 是的 加了 primary key constraint 后会强制将类型转成 Not nullable,这个是 primary key 的特性导致的。 > > Best, > Danny Chan > 在 2020年8月20日 +0800 PM5:19,xiao cai ,写道: > > 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, '-MM-dd > HH:mm:ss')), > > watermark for event_time AS event_time, > > PRIMARY KEY (shop_id, user_id) NOT ENFORCED > > ) with ( > > 'connector.type' = 'kafka', > > > > > > ) >
Re: DDL中声明主键会报类型不匹配
是的 加了 primary key constraint 后会强制将类型转成 Not nullable,这个是 primary key 的特性导致的。 Best, Danny Chan 在 2020年8月20日 +0800 PM5:19,xiao cai ,写道: > 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, '-MM-dd > HH:mm:ss')), > watermark for event_time AS event_time, > PRIMARY KEY (shop_id, user_id) NOT ENFORCED > ) with ( > 'connector.type' = 'kafka', > > > )
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, '-MM-dd HH:mm:ss')), watermark for event_time AS event_time, PRIMARY KEY (shop_id, user_id) NOT ENFORCED ) with ( 'connector.type' = 'kafka', )