Siddhi Query Language (SiddhiQL) is designed to process streams and identify complex event occurrences. Before we look into details of the Siddhi Query Language, let's take a look at a few definitions of terms.
|Event Stream||Logical series of events ordered in time|
|Event Stream Definition||Defines event streams. An event stream has a unique name and a set of typed attributes with uniquely identifiable names that define its schema.|
|Event||An event is associated with one event stream only, and all events of that stream have an identical set of typed attributes (or the same schema).|
|Attribute||Has a unique name within the event stream, and they have a type as INT, LONG, BOOLEAN, FLOAT, DOUBLE or STRING|
|Query||A logical construct that derives new streams by combining existing streams. Query contains some input streams, handlers to modify these input streams, and an output stream to which it publishes its output events.|
|Partition||A logical container that processes a subset of the query based on a pre-defined rule of separation.|
|Partition Definition||Defines a partition. A partition is based on either a variable or a range.|
Siddhi queries describe how to combine existing event streams to create new event streams. When deployed in the Siddhi runtime, Siddhi queries process incoming event streams, and as specified by the queries, they generate new output event streams if they don’t exist.
For example, let us consider an event stream called StockExchangeStream that has three parameters: ‘symbol’ of type String, ‘price’ of type float, and ‘volume’ of type int.
from StockExchangeStream[volume <10]
select symbol, volume
insert into StockQuoteStream partition by StockSymbol
The above query will create a new stream called ‘StockQuoteStream’, that has two attributes as ‘symbol’ of type STRING and ‘volume’ of type INT having events from StockExchangeStream that have the volume attribute less than 10. It will also create a separate partition for processing of each stock symbol.