0

I need some help concerning the CEP engine Esper: I wrote the following statement:

SELECT clientID FROM MovementEvent.win:time_batch(5 sec) GROUP BY clientID

And then I sent a MovementEvent into the engine. after 5 seconds, the subscriber is triggered - ok. But after 5 more seconds, it is triggered again - why?

No matter how many events I send to the engine, the subscriber always is triggered twice - after 5 and 10 seconds

I hope you could help me!

Thanx ;)

2 Answers2

0

What you need is this:

SELECT clientID FROM MovementEvent.std:groupwin(clientID).win:time_batch(5 sec);

In general, using GROUP BY without an aggregation function applied to the properties you are selecting will almost always catch you off-guard :). For the sake of it, this statement would also produce what you expected:

SELECT distinct(clientID) FROM MovementEvent.win:time_batch(5 sec);

This link will probably explain the differences better: http://www.espertech.com/esper/release-5.2.0/esper-reference/html/epl_clauses.html#epl-group-by-versus-view

xpa1492
  • 1,953
  • 1
  • 10
  • 19
0

The group-by makes this an aggregation and Esper provides output when there is a change in the aggregation for the keys, even if you don't select aggregations. You could do this one

select window(*).distinctOf(v=>client) from MovementEvent.win:time_batch(5 sec)
user650839
  • 2,594
  • 1
  • 13
  • 9