我正在使用一个简单的SiddhiQL查询来获取具有相同时间戳的记录数,直到分钟输入和这些时间戳。查询是:
from inputStream
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(formatedTs)
group by formatedTs
insert into outputStream;
它给了我错误mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN}
。在这种情况下,group by
子句有什么问题?
答案 0 :(得分:0)
错误原因:
由于AS
count(formatedTs)
,因此出现此特定错误
(这也在错误消息中指出。
mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<',
'<=', '>', '>=', '==', '!=', AS, OR, AND, IN}
由于缺少group
}
AS
位置错误
需要更正:
所以select
语句需要更正如下:
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(formatedTs) as tsCount
您可能需要进一步修正:
此外,inputStream
是否有名为formatedTs
的属性?如果没有,在修复select
语句后,您将收到如下错误:
无法找到属性类型,因为'inputStream'中不存在'formatedTs'
因为您正在计算的属性应存在于inputStream
如果是这种情况,以下查询(应该成功编译)可能对您有所帮助:
from inputStream
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(ts) as countTs
group by ts
insert into outputStream;
更新查询,因为您的要求是按格式化的时间戳进行分组:
from inputStream
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs
insert into innerStream;
from innerStream
select formatedTs, count(formatedTs) as countTs
group by formatedTs
insert into outStream;