Hi, Benchao, thank you for your report. It looks egacy planner and blink planner have different behavior. Could you create an issue in https://issues.apache.org/jira/browse/FLINK <https://issues.apache.org/jira/browse/FLINK> ?
> On Dec 15, 2019, at 16:17, Benchao Li <libenc...@gmail.com> wrote: > > hi all, > > We are using 1.9.0 blink planner, and find flink will throw NPE when we use > the following SQL: > > ``` > create table source { > age int, > id varchar > }; > select *case when age < 20 then cast(id as bigint) else 0 end* from source; > ``` > > After debugging the Janino generated code, I find that NPE's reason is that > `BinaryStringUtil.toLong` returns `null`, and we assign this result to a > `long` field. > > Then a tried old planner, it throw a `java.lang.NumberFormatException` when > casting a blank string to int. > And also tried other illegal casting in blink, which come out to be `null`. > > So, here is my question: > Obviously, this is a bug in blink planner, and we should fix that. But we > have two ways to fix this: > 1, make behavior of cast behave like before, which produces `null`, > 2, change the behavior of blink planner to align with old planner, which > produces `NumberFormatException`. > > > > Benchao Li > School of Electronics Engineering and Computer Science, Peking University > Tel:+86-15650713730 > Email: libenc...@gmail.com; libenc...@pku.edu.cn