Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-15266

NPE in blink planner code gen

    XMLWordPrintableJSON

Details

    Description

      `cast` function in blink planner and old planner are different:

      in legacy planner:
      cast('' as int) -> throw NumberFormatException
      cast(null as int) -> throw NullPointerException
      cast('abc' as int) -> throw NumberFormatException

      but in blink planner:
      cast('' as int) -> return null
      cast(null as int) -> return null
      cast('abc' as int) -> return null

      A step forward:
      ```
      create table source

      { age int, id varchar }

      ;
      select case when age < 20 then cast(id as bigint) else 0 end from source;
      ```
      queries like above will throw NPE because we will try assign a `null` to a `long` field when the input satisfy `age < 20`.

      Attachments

        Issue Links

          Activity

            People

              libenchao Benchao Li
              libenchao Benchao Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m