SiddhiQL query Error : mismatched input 'group'

SiddhiQL query Error : mismatched input 'group'

我正在使用一个简单的 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 子句在这种情况下有什么问题?

错误原因:

此特定错误是由于缺少 AS,跟随 count(formatedTs)

(这也在错误消息中指出。 mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN} 由于缺少 AS)

,查询编译器认为 group 在错误的位置

需要更正:

所以select语句需要更正如下:

select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(formatedTs) as tsCount

您可能需要进一步更正:

此外,inputStream 是否有一个名为 formatedTs 的属性?如果不是,在修复 select 语句后,您将收到另一个错误,如下所示:

Cannot find attribute type as 'formatedTs' does not exist in 'inputStream'

因为您要计数的属性应该存在于 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;