apache-kafkaapache-flinkflink-streamingflink-sql

Why does Flink Table with Kafka Connector not return results for window-based aggregation operations?


I created a table with

    create table Bid(    
        auction  BIGINT,
        bidder  BIGINT,
        price  BIGINT,
        channel  VARCHAR,
        url  VARCHAR,
        dateTime  TIMESTAMP(3),
        extra  VARCHAR,
         `record_time` TIMESTAMP_LTZ(3) METADATA FROM 'tenter image description hereimestamp' ,  
        WATERMARK FOR dateTime AS dateTime - INTERVAL '4' SECOND)
  with (    'connector' = 'kafka',
    'topic' = 'test',
    'properties.bootstrap.servers' = 'localhost:9092',
    'properties.group.id' = 'testGroup',
    'scan.startup.mode' = 'latest-offset',
    'format' = 'csv');

and when I run

 SELECT window_start, window_end, COUNT(*)

 FROM TABLE(

     TUMBLE(TABLE Bid, DESCRIPTOR(dateTime), INTERVAL '1' SECOND))

 GROUP BY window_start, window_end;

no matter how long I run the data generator, no result is returned.

but I'm sure there's data falls in the window, as I can get results from

select `record_time`,window_start, window_end
FROM TABLE(TUMBLE(TABLE Bid, DESCRIPTOR(dateTime), INTERVAL '1' SECOND));

the result is

results

I checked the Flink web monitor and I can see there are records received

enter image description here

enter image description here


Solution

  • try run this SELECT window_start, max(window_end) window_end, COUNT(*) FROM TABLE(TUMBLE(TABLE Bid, DESCRIPTOR(dateTime), INTERVAL '1' SECOND)) GROUP BY window_start;

    or make sure dateTime is increasing, then you will have the expected result.