You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Shuiqiang Chen (Jira)" <ji...@apache.org> on 2023/04/23 08:28:00 UTC

[jira] (FLINK-31848) And Operator has side effect when operands have udf

    [ https://issues.apache.org/jira/browse/FLINK-31848 ]


    Shuiqiang Chen deleted comment on FLINK-31848:
    ----------------------------------------

was (Author: csq):
Hi [~zju_zsx],

take a table MyTable(a INT, b INT) for instance, there are three rows:
(1, 1), 
(null, 2), 
(3, 3)

and for the query

select * from MyTable where a < 2 and b < 2

the value of left.nullTerm and left.resultTerm would be:

false, true // a is not null, then evaluate the reuslt of a < 2 to be true, need to evaluate right code
true, false // a is null, means the result of a < 2 is UNKNOWN, no need to evaluate a < 2 but to evalute b < 2 as right.code
false, false // a is not null, then evaluate the result of a < 2 to be false, no need to evaluate right code

by simplying to if(!left.resultTerm), we assuem the result of null < 2 to be false, but actually it is UNKNOWN.

For the correctness, if(!left.resultTerm) and if(!left.nullTerm && !left.resultTerm) are identical. Since the generated code is not exposed to users and not affecting the correctness, the two implementations are fine for me.



> And Operator has side effect when operands have udf
> ---------------------------------------------------
>
>                 Key: FLINK-31848
>                 URL: https://issues.apache.org/jira/browse/FLINK-31848
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.13.2
>            Reporter: zju_zsx
>            Priority: Major
>         Attachments: image-2023-04-19-14-54-46-458.png
>
>
>  
> {code:java}
> CREATE TABLE kafka_source (
>    `content` varchar,
>    `testid` bigint,
>    `extra` int
>    );
> CREATE TABLE console_sink (
>    `content` varchar,
>    `testid` bigint
>  )
>   with (
>     'connector' = 'print'
> );
> insert into console_sink
> select 
>    content,testid+1
> from kafka_source where testid is not null and testid > 0 and my_udf(testid) != 0; {code}
> my_udf has a constraint that the testid should not be null, but the testid is not null and testid > 0 does not take effect.
>  
> Im ScalarOperatorGens.generateAnd
> !image-2023-04-19-14-54-46-458.png!
> if left.nullTerm is true, right code will be execute 。
> it seems that
> {code:java}
> if (!${left.nullTerm} && !${left.resultTerm}) {code}
> can be safely replaced with 
> {code:java}
> if (!${left.resultTerm}){code}
> ? 



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