flink 滑动窗口

 

 

 

 

 

 

create table tb_orders (
order_time TIMESTAMP(3),product_id STRING,price FLOAT,
WATERMARK FOR order_time AS order_time - INTERVAL '0' MINUTE
) with (
'connector' = 'kafka',
'scan.startup.mode' = 'earliest-offset',
'topic' = 'todd_fx_tumble01',
'properties.bootstrap.servers' = '10.1.2.3:9092',
'value.format' = 'json'
);
SELECT
HOP_START(order_time, INTERVAL '1' MINUTE, INTERVAL '10' MINUTE) AS win_start,
HOP_END(order_time, INTERVAL '1' MINUTE, INTERVAL '10' MINUTE) AS win_end,
SUM(price) AS total
FROM tb_orders
group by
HOP(order_time, INTERVAL '1' MINUTE, INTERVAL '10' MINUTE)

 

posted @ 2021-12-13 18:29  tonggc1668  阅读(135)  评论(0编辑  收藏  举报