How to get all data of one column in the aggregation siddhi query. For example, i have the data as:
column1 column2 column_uuid
1 a uuid1
2 a uuid1
3 a uuid3
4 b uuid4
I want to use the siddhi query as:
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;
and i want get result as:
Event{timestamp=xxx, data=[a, 3, "uuid1,uuid2,uuid3"]}
In Siddhi, there are two types of functions. Regular "function"s, and "aggregate-function"s. Since str:concat() is not an aggregate-function, you can't use that to get your desired outcome.
Therefore, you may have to write your own custom:concat()
aggregate function to get that expected result. Please refer to following samples on writing a custom aggregate functions (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).