from <stream>#<window> [unidirectional]
join <stream>#<window> [unidirectional]
[on <condition>] [within <time>]
insert [<output-type>] into <stream-name> ( {<attribute-name>}| ‘*’)
- Join takes two streams as the input
- Each stream must have an associated window
- It generates the output events composed of one event from each stream
- With “on <condition>” Siddhi joins only the events that matches the condition
- With “within <time>”, Siddhi joins only the events that are within that time of each other
Following example shows a join query.
Outputs the matching events via JoinStream from last 2000 TickEvent and the NewsEvent that have arrived within 500 msec.
from TickEvent[symbol==’IBM’]#window.length(2000) join
NewsEvent#window.time(500)
insert into JoinStream *
Join can be in multiple forms
1. join - inner join
2. [((left|right|full) outer) | inner] join - only inner join is supported in the current version
When we join two streams, the events arriving at either stream will trigger a joining process. Siddhi also supports a special ‘unidirectional’ join. Here only one stream (the stream defined with the ‘unidirectional’ keyword ) will trigger the joining process.
Following shows a sample unidirectional join query
When an event arrives at the TickEvent that will be matched with all NewsEvents that have arrived within 500 msec, and if the TickEvent’s symbol == NewsEvent’s company, the output event will be generated and sent via JoinStream.
from TickEvent[symbol==’IBM’]#window.length(2000) as t unidirectional
join NewsEvent#window.time(500) as n
on t.symbol == n.company
insert into JoinStream *
Here ‘join’ only triggered when events arrives in TickEvent stream.
When no projection is given or when ‘*’ is used, the output stream attributes will contain both the input events attributes, and the output attributes will be named as <input-stream-name>_<attribute> to maintain uniqueness.