If-Then-Else
This application demonstrates how to enrich events based on a simple if-then-else conditions.
define stream TemperatureStream
(sensorId string, temperature double);
@info(name = 'SimpleIfElseQuery')
from TemperatureStream
select sensorId,
ifThenElse(temperature > -2, 'Valid', 'InValid') as isValid
insert into ValidTemperatureStream;
@info(name = 'ComplexIfElseQuery')
from TemperatureStream
select sensorId,
ifThenElse(temperature > -2,
ifThenElse(temperature > 40, 'High', 'Normal'),
'InValid')
as tempStatus
insert into ProcessedTemperatureStream;
|
Defines |
|
|
|
if |
|
|
|
|
|
If the |
|
Events at each stream
When an event with values ['sensor1'
, 35.4
] is sent to TemperatureStream stream it will get converted and travel through the streams as below.
- ValidTemperatureStream : [
'sensor1'
,'Valid'
] - ProcessedTemperatureStream : [
'sensor1'
,'Normal'
]