0

I'm new in Esper. Can anyone help me define the EPL statement to catch the event when the following situation occurs:

  • Assumming that there are events with 3 attributes - (string)Symbol, (boolean)Value, (datetime)Timestamp. For example event1 (Symbol-apple, Value-true, Timestamp- 2020.10.07 14:00:00), event2 (Symbol-orange, Value-true, Timestamp- 2020.10.07 14:00:00) and event3 (Symbol-banana, Value-false, Timestamp- 2020.10.07 14:00:00). If they have same (or almost the same) Timestamp only one of them can have attribute - Value as true. In this example event2 matchs the requirement and should be captured.

How can I define the statement to catch it?

Thanks for any help.

Narsu

Narsu
  • 1

1 Answers1

0

The "window" is an aggregation function (see manual) returns the events. The enumeration methods (selectfrom, countof, see manual) are for filtering and selecting. Something like this.

select window(*).selectFrom(v => v.value=true) as eventWithTrueFlag
from Event#length(3) 
having window(*).countOf(v => v.value=true)=1 and 
  prev(1, timestamp)=timestamp and prev(2, timestamp)=timestamp

"Event" is your event type. You didn't say what your event type is named. "Prev" is the previous function (see manual).

user650839
  • 2,594
  • 1
  • 13
  • 9
  • Hey thanks for your reply. I've tried your tip but got an exception - Failed to resolve event type, named window or table by name 'Event' - ... Can you please explain your code more detaily? here is window(*) an agg function you mentioned? .selectFrom... and countOf ... are enumeration methods? what are the prev(1, ts) and prev(2, ts) doing? thanks in advance :) – Narsu Oct 08 '20 at 05:41