[
https://issues.apache.org/jira/browse/FLINK-30966?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17687683#comment-17687683
]
Shuiqiang Chen commented on FLINK-30966:
----------------------------------------
[~luoyuxia]The matter of
[FLINK-31003|https://issues.apache.org/jira/browse/FLINK-31003] is return type
inferencing, while there is another issue that the code block of result term
casting might be wrong.
> 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)