Hi All, I have a System Function (IF AND CASE WHEN...
# troubleshooting
w
Hi All, I have a System Function (IF AND CASE WHEN) issue occurred. I using Flink 1.15.0 + with Flink SQL.
Copy code
-- when i execute this sql, i can get the correct result
SELECT IF(`marketing_flow_id` IS NOT NULL, `marketing_flow_id`, '') FROM source;

-- when i execute this sql, i get the error result(return  blank)
SELECT IF(`marketing_flow_id` IS  NULL, '', `marketing_flow_id`) FROM source;
maybe this is a bug ?
here is my code
Copy code
CREATE TEMPORARY TABLE source (
  mktgmsg_biz_type STRING,
  marketing_flow_id STRING,
  mktgmsg_campaign_id STRING
)
WITH
(
  'connector' = 'filesystem',
  'path' = 'file:///Users/xxx/Desktop/demo.json',
  'format' = 'json'
);
here is my data
Copy code
{
  "mktgmsg_biz_type": "mktgmsg_campaign",
  "marketing_flow_id": "marketing_flow_id",
  "mktgmsg_campaign_id": "mktgmsg_campaign_id"
}
meanwhile i use case when also occurred this isue
Copy code
-- expect result is 'mktgmsg_campaign_id', but i got blank

select CASE
  WHEN `mktgmsg_biz_type` = 'marketing_flow'     THEN IFNULL(`marketing_flow_id`, '')
  WHEN `mktgmsg_biz_type` = 'mktgmsg_campaign'   THEN IFNULL(`mktgmsg_campaign_id`, '')
  ELSE ''
  END AS `message_campaign_instance_id` FROM source;
when i run in Flink 1.12.5, both are all right.