[ 
https://issues.apache.org/jira/browse/FLINK-30966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17686842#comment-17686842
 ] 

Shuiqiang Chen edited comment on FLINK-30966 at 2/10/23 2:38 AM:
-----------------------------------------------------------------

Hi [~hiscat], I have reproduced the same error and it seems a bug in IFCallGen.
There are two problems.
1. It do the result term casting before the calculation logic, and finally the 
actual result always refer to a non-initialized field.
2. when normalizing arguments, it always align to the type of ARG1, like IF(1 > 
 2, 'true', 'false')
the result will be string 'fals' which length is the same as 'true'.

I would like to help fix it. 


was (Author: csq):
Hi [~hiscat], I have reproduced the same error and it seems a bug in IFCodeGen.
There are two problems.
1. It do the result term casting before the calculation logic, and finally the 
actual result always refer to a non-initialized field.
2. when normalizing arguments, it always align to the type of ARG1, like IF(1 > 
 2, 'true', 'false')
the result will be string 'fals' which length is the same as 'true'.

I would like to help fix it. 

> Flink SQL IF FUNCTION logic error
> ---------------------------------
>
>                 Key: FLINK-30966
>                 URL: https://issues.apache.org/jira/browse/FLINK-30966
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.16.0, 1.16.1
>            Reporter: 谢波
>            Priority: Major
>
> my data is 
> {code:java}
> //
> { "before": { "status": "sent" }, "after": { "status": "succeed" }, "op": 
> "u", "ts_ms": 1671926400225, "transaction": null } {code}
> my sql is 
>  
> {code:java}
> CREATE TABLE t
> (
>     before ROW (
>         status varchar (32)
>         ),
>     after ROW (
>         status varchar (32)
>         ),
>     ts_ms                bigint,
>     op                   string,
>     kafka_timestamp      timestamp METADATA FROM 'timestamp',
> --     @formatter:off
>     proctime AS PROCTIME()
> --     @formatter:on
> ) WITH (
>     'connector' = 'kafka',
> --     'topic' = '',
>     'topic' = 'test',
>     'properties.bootstrap.servers' = ' ',
>     'properties.group.id' = '',
>     'format' = 'json',
>     'scan.topic-partition-discovery.interval' = '60s',
>     'scan.startup.mode' = 'earliest-offset',
>     'json.ignore-parse-errors' = 'true'
>  );
> create table p
> (
>     status                  STRING ,
>     before_status                  STRING ,
>     after_status                  STRING ,
>     metadata_operation      STRING COMMENT '源记录操作类型',
>     dt                      STRING
> )WITH (
>     'connector' = 'print'
>  );
> INSERT INTO p
> SELECT
>        IF(op <> 'd', after.status, before.status),
>         before.status,
>         after.status,
>        op                                         AS metadata_operation,
>        DATE_FORMAT(kafka_timestamp, 'yyyy-MM-dd') AS dt
> FROM t;
>  {code}
>  my local env output is 
>  
>  
> {code:java}
> +I[null, sent, succeed, u, 2023-02-08] {code}
>  
>  my produtionc env output is 
> {code:java}
> +I[sent, sent, succeed, u, 2023-02-08]  {code}
> why?  
> This look like a bug.
>  



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

Reply via email to