E.g. A stream named
TempStream can be created with the following attributes as shown below.
|Attribute Name||Attribute Type|
define stream TempStream (deviceID long, roomNo int, temp double);
SiddhiQL supports the following for query projection.
|Selecting required objects for projection|
This involves selecting only some of the attributes in an input stream to be inserted into an output stream.
e.g., The following query selects only the roomNo and temp attributes from the
|Selecting all attributes for projection|
This involves selecting all the attributes in an input stream to be inserted into an output stream. This can be done by using the asterisk sign ( * ) or by omitting the
e.g., Use one of the following queries to select all the attributes in the
This involves selecting attributes from the input streams and inserting them into the output stream with different names.
e.g., The following query renames
|Introducing the default value|
This involves adding a default value and assigning it to an attribute using
|Using mathematical and logical expressions|
This involves using attributes with mathematical and logical expressions to the precedence order given below, and assigning them to the output attribute using
e.g., Converting Celsius to Fahrenheit and identifying server rooms
A function consumes zero, one or more function parameters and produces a result value.
Time is a special parameter that can we defined using the time value as int and its unit type as <int> <unit>. Following are the supported unit types, Time upon execution will return its expression in the scale of milliseconds as a long value.
|Year||year | years|
|Month||month | months|
|Week||week | weeks|
|Day||day | days|
|Hour||hour | hours|
|Minutes||minute | minutes | min|
|Seconds||second | seconds | sec|
|Milliseconds||millisecond | milliseconds|
E.g. Passing 1 hour and 25 minutes to test function.
The above syntax contains the following:
<event window name>
|A unique name for the window.|
<attribute name> <attribute type>
|These elements define a set of attributes assigned specific types.|
Any inbuilt window type available in Siddhi. For the complete list of available window types, see Inbuilt Windows.
<output event type>
The possible values for this parameter are as follows:
If the output event type is not specified for an event window, it emits both current and expired events.
Sample event window definitions
The query for inserting events into a window is similar to the query for inserting events into event streams where the
insert into <window name> code snippet is used. To restrict the events inserted into the window by a specific category, use one of the following key words between the
|To insert only current events into the event window.|
| ||To insert only expired events into the event window.|
| ||To insert both current and expired events into the event window.|
e.g., The following query inserts both current and expired events from an event stream named
sensorStream to an event window named
The parameters used in the query are as follows.
|The logging priority. Possible values are |
| ||This parameter allows you to specify a message to be printed in the log.|
| ||This parameter specifies whether the event body should be included in the log. Possible values are |
The following examples illustrate the variations of the Siddhi logger.
- Function Extension
- Aggregate Function Extension
- Window Extension
- Stream Function Extension
- Stream Processor Extension