flink sql hop函数窗口时间前移问题

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

flink sql hop函数窗口时间前移问题

bigdata
你好:
        我是用的flink1.10.1,使用滑动窗口时候,第一个窗口的开启时间会前移。前移时长=窗口时长-滑动步长。这就导致刚接到的第一条数据(在前移时长范围内)一直参与计算。如何解决,谢谢!
SELECT
|    DATE_FORMAT(TIMESTAMPADD(HOUR, 8, HOP_START(proctime, INTERVAL '$slide' SECOND, INTERVAL '$size' MINUTE)), 'yyyy-MM-dd HH:mm:ss') start_time,
|    UNIX_TIMESTAMP(DATE_FORMAT(TIMESTAMPADD(HOUR, 8, HOP_START(proctime, INTERVAL '$slide' SECOND, INTERVAL '$size' MINUTE)), 'yyyy-MM-dd HH:mm:ss')) * 1000 AS `time`,
|    CAST(COUNT(distinct drive_id) AS INT) num
|  FROM
|    ${databaseName}.log_stream
|  WHERE
|    req_type = '1' and navigation_flag=' '
|  GROUP BY
|    HOP(proctime, INTERVAL '$slide' SECOND, INTERVAL '$size' MINUTE)
3> 2021-01-15 13:43:20,1610689400000,1
4> 2021-01-15 13:43:30,1610689410000,2
1> 2021-01-15 13:43:40,1610689420000,3
2> 2021-01-15 13:43:50,1610689430000,3
3> 2021-01-15 13:44:00,1610689440000,3
4> 2021-01-15 13:44:10,1610689450000,3
1> 2021-01-15 13:44:20,1610689460000,3
2> 2021-01-15 13:44:30,1610689470000,3
3> 2021-01-15 13:44:40,1610689480000,3
4> 2021-01-15 13:44:50,1610689490000,3
1> 2021-01-15 13:45:00,1610689500000,3
2> 2021-01-15 13:45:10,1610689510000,3
3> 2021-01-15 13:45:20,1610689520000,3