Use a KEEP UNTIL clause with a Jumping Window.
CREATE SCHEMA TradesSchema (
Id integer
Symbol string
Price float
Shares integer
) ;
CREATE INPUT STREAM Trades
SCHEMA TradesSchema ;
The
example then creates a Flex statement named Until8PM_Flex that
operates on Trades and produces an output window named
Until8PM. The example deletes all previous rows every five
seconds, and purges all the data in Until8PM at 8:00 PM once a
day.CREATE FLEX Until8PM_Flex
IN Trades
OUT OUTPUT WINDOW Until8PM
SCHEMA TradesSchema
PRIMARY KEY (Id)
BEGIN
DECLARE
date lastPurgeDate;
END;
ON Trades {
};
EVERY 1 MINUTE {
if (isnull(lastPurgeDate) or (trunc(sysdate()) >
lastPurgeDate and hour (sysbigdatetime()) = 20)) {
for(rec in Until8pm_stream) {
output setopcodes(rec, delete);
}
lastPurgeDate := trunc(sysdate());
}
};
END;