Hi, - 首先1.10中把char Insert到varchar中是支持的,可以再check下哪里有没有问题吗? - 'false'应该是char(5)而不是char(4)
Best, Jingsong Lee On Tue, Apr 21, 2020 at 9:01 PM Leonard Xu <xbjt...@gmail.com> wrote: > Hi > > CHAR(n) 、VARCHAR 在SQL语义里是不同的类型,SQL里写的 ‘false’ 常量会解析到CHAR(n) > 因为常量长度已经确定会选择使用CHAR(n), > 目前是Flink还不支持CHAR(n) 和 VARCHAR 类型之间的隐式转换,所以类型检查会报错,你可以先用CAST(‘false’ as > VARCHAR)后处理。 > > 祝好 > Leonard > > > 在 2020年4月21日,18:32,王双利 <all...@163.com> 写道: > > > > hit声明的是varchar,现在是,'false' 编译的时候认为是char(4) ,导致类型不匹配 > > > > > > > > 王双利 > > > > 发件人: Leonard Xu > > 发送时间: 2020-04-21 18:29 > > 收件人: user-zh > > 主题: Re: flink sql string char 不兼容? > > Hi > > Sink 对应的字段(taskid\hit)需要声明成varchar, 现在不支持varchar类型写入char(n) > > > > 祝好, > > Leonard Xu > > > >> 在 2020年4月21日,18:20,王双利 <all...@163.com> 写道: > >> > >> 下面的sql 执行的时候报 下面的错误CREATE TABLE target ( > >> jnlno VARCHAR, > >> -- taskid char(9), > >> -- hit char(4) > >> taskid VARCHAR, > >> hit VARCHAR > >> ) > >> insert into target select a.jnlno,'111111qeq','false' from loginevent > a > >> > >> Exception in thread "main" > org.apache.flink.table.api.ValidationException: Type STRING of table field > 'hit' does not match with the physical type CHAR(4) of the 'EXPR$2' field > of the TableSink consumed type. > >> > >> Flink 版本 1.10 > >> 怎么解决呢?Flink sql的 string char 不兼容? > >> sql应该怎么写合适呢? > > -- Best, Jingsong Lee