一、参考
二、window
三、示例
3.1 准备csv
文件
bid.csv
如下
supplier1,C,40,2020-04-15 08:05:00.0
supplier1,A,20,2020-04-15 08:07:00.0
supplier2,D,50,2020-04-15 08:09:00.0
supplier2,B,30,2020-04-15 08:11:00.0
supplier1,E,10,2020-04-15 08:13:00.0
supplier2,F,20,2020-04-15 08:17:00.0
3.2 创建table
/*
创建bid表
注意:
(1) csv 文件中不需要添加header;
(2) timestamp(3) 的格式为 2021-09-02 01:00:00.000, 即表示可以精确到秒后小数点3位
*/
create table bid (
supplier_id STRING,
item STRING,
price INT,
bidtime TIMESTAMP(3),
WATERMARK FOR bidtime AS bidtime - INTERVAL '1' SECOND
) with (
'connector' = 'filesystem',
'path' = '/Users/yz/work/github/flinkLearn/csvs/bid.csv',
'format' = 'csv'
);
3.3 hop
滑动窗口
/*
bid 查询语句, 滑动窗口
*/
select window_start, window_end,sum(price) from table(
hop(table bid, descriptor(bidtime), interval '5' minutes, interval '10' minutes)
)
group by window_start, window_end;
select hop_start(bidtime, interval '2' minute, interval '4' minute) as hop_start,
hop_end(bidtime, interval '2' minute, interval '4' minute) as hop_end,
sum(price) as sum_price from bid group by hop(bidtime, interval '2' minute, interval '4' minute);
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。