Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-30966

Flink SQL IF FUNCTION logic error

    XMLWordPrintableJSON

Details

    Description

      my data is 

      //
      { "before": { "status": "sent" }, "after": { "status": "succeed" }, "op": "u", "ts_ms": 1671926400225, "transaction": null } 

      my sql is 

       

      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;
      
       

       my local env output is 

       

       

      +I[null, sent, succeed, u, 2023-02-08] 

       

       my produtionc env output is 

      +I[sent, sent, succeed, u, 2023-02-08]  

      why?  
      This look like a bug.

       

      Attachments

        Issue Links

          Activity

            People

              csq Shuiqiang Chen
              hiscat 谢波
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: