How to get the latest event‘s element(should filter null value) that group by some keys

293 Views Asked by At

I am a new using esper, I got a problem that did not know how to construct the EPL.

my event has these elements(key,index,e0,e1,e2....) ,and in every event e1 may exist or not, I want get latest "index"'s element:“e1”(exluding null value) and sum(e2) group by “key”.

I wrote a EPL like this:

 select key, sum(e2), maxby(index).e1 as e1 from Event.win:time_batch(3 sec) group by key

example output like below:

send event :{key=0, index=0, e0=5, e1=1}

send event :{**key=3**, index=1, **e1=2**, e2=6}

send event :{**key=3**, index=2, e0=0, e3=2}   **//the event e1 is not exist**

send event :{key=1, index=3, e2=8, e3=4}

sliding win output: {key=0, sum(e2)=null, e1=1}

sliding win output: {key=1, sum(e2)=8, e1=null}

sliding win output: {**key=3**, sum(e2)=6, **e1=null**}

you see ,the result of [key=3]'s e1=null, but i expect to filter the e1=null event and should output e1=2

"maxby" can not add a condition like "fmax" function.

so how can I filter it in EPL?

1

There are 1 best solutions below

3
On

just add "...from Event(e1 is not null)..."