Type based Filtering

This application demonstrates filter out events based on data type of the attribute

define stream SweetProductionStream (name string, amount int);

@info(name='ProcessSweetProductionStream')
from SweetProductionStream
select 
   instanceOfInteger(amount) as isAIntInstance,
    name, 
    amount
insert into ProcessedSweetProductionStream;
define stream SweetProductionStream (name string, amount int);

Defines SweetProductionStream having information of name and amount

@info(name='ProcessSweetProductionStream')
from SweetProductionStream
select 
   instanceOfInteger(amount) as isAIntInstance,

true if amount is of int type

    name, 
    amount
insert into ProcessedSweetProductionStream;

Input

Below event is sent to SweetProductionStream,

['chocolate cake', 'invalid']

Output

After processing, the event arriving at ProcessedSweetProductionStream will be as follows:

[false, 'chocolate cake', 'invalid']

Top