小编Est*_*tel的帖子

如何使用 Presto 将时间列分组为 5 秒间隔并计算行数?

我正在使用 Presto 和 Zeppelin。有很多原始数据。我必须总结这些数据。

我想每 5 秒分组一次。

serviceType        logType     date
------------------------------------------------------
service1           log1        2017-10-24 23:00:23.206
service1           log1        2017-10-24 23:00:23.207
service1           log1        2017-10-24 23:00:25.206
service2           log1        2017-10-24 23:00:24.206
service1           log2        2017-10-24 23:00:27.206
service1           log2        2017-10-24 23:00:29.302
Run Code Online (Sandbox Code Playgroud)

那么结果

serviceType        logType     date                       cnt
--------------------------------------------------------------
service1           log1        2017-10-24 23:00:20          2
service2           log1        2017-10-24 23:00:20          1
service1           log1        2017-10-24 23:00:25          1
service1           log2        2017-10-24 23:00:25          2
Run Code Online (Sandbox Code Playgroud)

首先,我必须将存储的数据迁移到新表。

其次,我必须对数据进行分组并实时保存到新表中。

很难写sql脚本。

请帮我。

我必须使用 python 解释器吗?

sql presto apache-zeppelin

2
推荐指数
1
解决办法
2935
查看次数

标签 统计

apache-zeppelin ×1

presto ×1

sql ×1