如何在 siddhi 聚合查询中使用 "select concat(col)"?
how to use "select concat(col)" in siddhi aggregation query?
如何获取聚合siddhi查询中某一列的所有数据。例如,我的数据为:
column1 column2 column_uuid
1 a uuid1
2 a uuid1
3 a uuid3
4 b uuid4
我想将 siddhi 查询用作:
define stream Input (column1 int, column2 string, column_uuid string);
define stream Output (column2 string, amount long, uuid string);
@info(name='query')
from Input#window.time(30 sec)
select column2, count() as amount, concat(column_uuid) as uuid
group by column2
having amount > 2
insert into Output;
我希望得到的结果是:
Event{timestamp=xxx, data=[a, 3, "uuid1,uuid2,uuid3"]}
悉达语有两种功能。常规 "function"s, and "aggregate-function"s. Since str:concat() 不是聚合函数,您不能使用它来获得所需的结果。
因此,您可能必须编写自己的 custom:concat()
聚合函数才能获得预期结果。请参考以下有关编写自定义聚合函数的示例 (samples). To get the above output, you can simply keep a global string variable within your custom attribute aggregator and append to that in processAdd(Object data)
method (similar to this)。
如何获取聚合siddhi查询中某一列的所有数据。例如,我的数据为:
column1 column2 column_uuid
1 a uuid1
2 a uuid1
3 a uuid3
4 b uuid4
我想将 siddhi 查询用作:
define stream Input (column1 int, column2 string, column_uuid string);
define stream Output (column2 string, amount long, uuid string);
@info(name='query')
from Input#window.time(30 sec)
select column2, count() as amount, concat(column_uuid) as uuid
group by column2
having amount > 2
insert into Output;
我希望得到的结果是:
Event{timestamp=xxx, data=[a, 3, "uuid1,uuid2,uuid3"]}
悉达语有两种功能。常规 "function"s, and "aggregate-function"s. Since str:concat() 不是聚合函数,您不能使用它来获得所需的结果。
因此,您可能必须编写自己的 custom:concat()
聚合函数才能获得预期结果。请参考以下有关编写自定义聚合函数的示例 (samples). To get the above output, you can simply keep a global string variable within your custom attribute aggregator and append to that in processAdd(Object data)
method (similar to this)。