Impala : 运行 1 小时总和

Impala : Running sum of 1 hour

我想在1小时内统计每个ID的记录。我尝试了一些 IMPALA 查询,但没有成功。

我输入的数据如下:

预期输出为:

我试过了:

select
      concat(month,'/',day,'/',year,' ',hour,':',minute) time, id,
     count(1) over(partition by id order by concat(month,'/',day,'/',year,' ',hour,':',minute) range between '1 hour' PRECEDING AND CURRENT ROW) request
       from rt_request
       where
    concat(year,month,day,hour) >= '2019020318' 
group by id, concat(month,'/',day,'/',year,' ',hour,':',minute)

但是我遇到了异常。

RANGE 仅支持下限和上限 UNBOUNDED 或一个 UNBOUNDED 和另一个 CURRENT ROW。

任何 suggestion/help 将不胜感激。 提前致谢!

我认为您正在寻找给定 ID 跨天同一小时的计数。您可以简单地使用 row_number 来执行此操作。

select time,id,row_number() over(partition by id,hour order by concat(month,'/',day,'/',year,' ',hour,':',minute)) as total
from tbl