You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Yuan Kui (Jira)" <ji...@apache.org> on 2023/03/29 07:39:00 UTC

[jira] [Updated] (FLINK-31653) Using`if` statement for a string subtype of the row type may meet npe in code generated by codegen

     [ https://issues.apache.org/jira/browse/FLINK-31653?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yuan Kui updated FLINK-31653:
-----------------------------
    Description: 
When I use the `if` statement for the string subtype of the row type, the code generated by `IfCallGen` may meet npe. The case is:
{code:java}
-- if the value of 'nested' colmun is row(null, 10), the job will meet npe
CREATE TABLE NestedTable (
  nested row<name string, `value` int>
) WITH (
  ...
);

select
    if (nested.name is null, 'JKL', nested.name) AS nestedName
from NestedTable {code}
Three conditions are required for this bug :

1、use `if` statement

2、string subtype of row type

3、the string subtype element is null

 

After excluding the effect of java code spilitter, the original code generated by codegen like the picture(you can find the complete code generated by codegen in attached files),the assignment logic for `isNull$7` is between the line 142 and the line 154, so the value of `isNull$7` in line 96 is always false,  the line 97 will meets npe when `result$7` is null.

!image-2023-03-29-14-52-17-277.png!

The way to fix this issue is changing the location of casted codes, like this:

!image-2023-03-29-15-33-37-983.png!

  was:
When I use the `if` statement for the string subtype of the row type, the code generated by `IfCallGen` may meets npe. The case is:
{code:java}
-- if the value of 'nested' colmun is row(null, 10), the job will meets npe
CREATE TABLE NestedTable (
  nested row<name string, `value` int>
) WITH (
  ...
);

select
    if (nested.name is null, 'JKL', nested.name) AS nestedName
from NestedTable {code}
Three conditions are required for this bug :

1、use `if` statement

2、string subtype of row type

3、the string subtype element is null

 

After excluding the effect of java code spilitter, the original code generated by codegen like the picture(you can find the complete code generated by codegen in attached files),the assignment logic for `isNull$7` is between the line 142 and the line 154, so the value of `isNull$7` in line 96 is always false,  the line 97 will meets npe when `result$7` is null.

!image-2023-03-29-14-52-17-277.png!

The way to fix this issue is changing the location of casted codes, like this:

!image-2023-03-29-15-33-37-983.png!


> Using`if` statement for a string subtype of the row type may meet npe in code generated by codegen
> --------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-31653
>                 URL: https://issues.apache.org/jira/browse/FLINK-31653
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.16.1, 1.15.4, 1.18.0, 1.17.1
>            Reporter: Yuan Kui
>            Priority: Major
>             Fix For: 1.18.0
>
>         Attachments: image-2023-03-29-14-52-17-277.png, image-2023-03-29-15-33-37-983.png
>
>
> When I use the `if` statement for the string subtype of the row type, the code generated by `IfCallGen` may meet npe. The case is:
> {code:java}
> -- if the value of 'nested' colmun is row(null, 10), the job will meet npe
> CREATE TABLE NestedTable (
>   nested row<name string, `value` int>
> ) WITH (
>   ...
> );
> select
>     if (nested.name is null, 'JKL', nested.name) AS nestedName
> from NestedTable {code}
> Three conditions are required for this bug :
> 1、use `if` statement
> 2、string subtype of row type
> 3、the string subtype element is null
>  
> After excluding the effect of java code spilitter, the original code generated by codegen like the picture(you can find the complete code generated by codegen in attached files),the assignment logic for `isNull$7` is between the line 142 and the line 154, so the value of `isNull$7` in line 96 is always false,  the line 97 will meets npe when `result$7` is null.
> !image-2023-03-29-14-52-17-277.png!
> The way to fix this issue is changing the location of casted codes, like this:
> !image-2023-03-29-15-33-37-983.png!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)