简体   繁体   English

SiddhiQL查询错误:输入'group'不匹配

[英]SiddhiQL query Error : mismatched input 'group'

I am using a simple SiddhiQL query to get number of records having same timestamp till minute entry and these timestamps. 我使用一个简单的SiddhiQL查询来获取具有相同时间戳,直到分钟输入和这些时间戳的记录数。 The query is: 查询是:

from inputStream
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(formatedTs)
group by formatedTs
insert into outputStream;

It gives me the error mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN} . 它给出了错误的mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN}错误, mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN} What's wrong with group by clause in this context? 在这种情况下group by子句有什么问题?

Reason for the error: 错误原因:

This particular error is coming due to the missing AS , following count(formatedTs) 这个特殊的错误是由于丢失的AS ,在count(formatedTs)

(This is indicated in the error message as well. mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN} Query Compiler thinks group is in wrong place due to the missing AS ) (这也在错误消息中指出。 mismatched input 'group' expecting {'*', '+', '-', '/', '%', '<', '<=', '>', '>=', '==', '!=', AS, OR, AND, IN}查询编译器认为group由于缺少AS而位置错误

Correction needed: 需要更正:

So the select statement, needs to be corrected as below: 所以select语句需要更正如下:

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

Further correction which you might need: 您可能需要进一步修正:

Also, does the inputStream has an attribute named formatedTs ? 另外, inputStream是否有一个名为formatedTs的属性? If not, after fixing the select statement, you'll get another error like below: 如果没有,修复select语句后,您将收到如下错误:

Cannot find attribute type as 'formatedTs' does not exist in 'inputStream' 无法找到属性类型,因为'inputStream'中不存在'formatedTs'

because the attribute for which you are taking the count should exist in the inputStream 因为您要计算的属性应该存在于inputStream

If that is the case, following query (which should compile successfully) might help you: 如果是这种情况,以下查询(应该成功编译)可能会帮助您:

from inputStream
select time:dateFormat(ts,'yyyy-MM-dd HH:mm') as formatedTs, count(ts) as countTs
group by ts
insert into outputStream;

Update 更新

Updating the query since your requirement is to group by the formatted timestamp: 由于您的要求是按格式化的时间戳分组,因此更新查询:

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM