Search code examples
complex-event-processingesper

Simple subquery in Esper


I want to be able to nest queries expressed in Esper's EPL. Let's assume I want to detect this pattern: A -> (B -> C). (A, B and C are types of events, -> is EPL's sequence operator.)

Here is the query representing B -> C:

select * from pattern [every (b=B -> c=C)]

I would then like to do the following:

select * from pattern [every (a=A -> bc=
    (select * from pattern [every (b=B -> c=C)])
)]

Actually, it would be best if something like this would be possible:

select * from pattern [every (b=B -> c=C)]) as bc
select * from pattern [every (a=A -> bc)]

This way, the first query is just bound to an identifier bc, which can then be used in the second query. That would be awesome!

Could someone please tell me if similar syntax exists in EPL? I appreciate any hint!


Solution

  • The query could simply be...

    every (a=A -> (every (b=B -> c=C))]
    

    Or insert "bc" into another stream and use that...

    insert into BCStream select * from pattern[every b=B -> c=C]; // also note lack of parens
    

    and

    select * from pattern[a=A -> BCStream]