我在处理多设备多测点的数据时遇到了一个问题,希望能够得到一些帮助。我有一组数据,每条数据都包含设备编码(DevCode)、指标名称(Metric)、时间(Time)以及对应的数值(Value)。现在,我想针对每个设备的单一指标进行时间窗口的聚合计算。
以下是一些数据示例:
{"devCode":"W001","metric":"WdSpd","time":"2023-08-26 17:36:06","Value":4.7}
{"devCode":"W002","metric":"WdSpd","time":"2023-08-26 17:36:06","Value":5.6}
{"devCode":"W003","metric":"WdSpd","time":"2023-08-26 17:36:06","Value":4.5}
{"devCode":"W004","metric":"WdSpd","time":"2023-08-26 17:36:06","Value":5.1}
{"devCode":"W001","metric":"Tmp","time":"2023-08-26 17:36:06","Value":53.5}
{"devCode":"W002","metric":"Tmp","time":"2023-08-26 17:36:06","Value":56.7}
{"devCode":"W003","metric":"Tmp","time":"2023-08-26 17:36:06","Value":55.2}
{"devCode":"W004","metric":"Tmp","time":"2023-08-26 17:36:06","Value":49.8}
我的目标是对每个设备的单一指标,例如风速(WdSpd)和温度(Tmp),进行时间窗口的聚合计算。
我参考了官方的 SQL 文档,并尝试使用以下 SQL 查询来实现我的需求:
SELECT
devCode,
"WNAC_WdSpd_10s" AS metric,
MAX(Value) AS value,
WINDOW_END() AS time
FROM mysource
GROUP BY devCode, TUMBLINGWINDOW(ss, 10)
然而,我发现这个 SQL 查询并没有产生我预期的结果。
我在这里寻求帮助,是否有更好的方法或者修改建议,能够让我正确地对多设备多测点的数据进行时间窗口的聚合计算?