Search code examples
esper

How to Batching ESPER EPL events


I'm trying to batch Notification events like this and I'm getting one Notifications event with a single notification event. Can anyone help me?

Thnks in advance.

Relevant Statements

INSERT INTO Notification SELECT d.id as id,a.stationId as stationId,d.firebaseToken as firebaseToken, d.position as devicePos,a.location as stationPos,a.levelNumber as levelNumber,a.levelName as levelName FROM AirQualityAlert.win:time(3sec) as a, device.win:time(3sec) as d WHERE d.position.distance(a.location) < 300

INSERT INTO Notifications SELECT * FROM Notification.std:groupwin(id).win:time_batch(20sec) for grouped_delivery(id)

Solution

  • This solution delivers a row per 'id' that contain a column with the list of events.

    create context Batch20Sec start @now end after 20 sec;
    context Batch20Sec select id, window(*) as data 
    from Notifications#keepall 
    group by id 
    output all when terminated;
    

    I think that is what you want.