Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Icon

Description
Tip
iconfalse
titleBefore you add a window query:

You need to add and configure the following:

  • The input stream with the events to be processed by the query.
  • The output stream to which the events processed by the query are directed.

Window queries include a window to select a subset of events to be processed based on a specific criterion. For more information, see Siddhi Query Guide - (Defined) Window .

Form

Once you connect the query to an input stream (source) and an output stream (target), move the cursor over the query and click the settings icon on the window query (shown below) to open the Query Configuration form.

  • Input: This section specifies the stream to be considered as the input stream with the events to which the query needs to be applied. The input stream connected to the query as the source is automatically displayed.
  • Select: This section specifies the attributes to be included in the output. In the Select field, you can select All Attributes to select all the attributes of the events, or select User Defined Attributes to select specific attributes, and the expressions to convert them as required to generate output events.
  • Output: This section specifies the action to be performed on the output event. The fields to be configured in this section are as follows:
    • Operation: This field specifies the operation to be performed on the generated output event (e.g., Insert to insert events to a selected stream/table/window).
    • Into: This field specifies the stream/table/window in which the operation specified need to be performed.
    • For: This field specifies whether the operation needs to be performed for all output events, only current events or for only expired events.
  • Stream Handlers: This section can be used to configure the window. To do this, select Window in the Stream Handler field, and then enter information in the following fields.

    • Window Name: A unique name for the window.
    • Parameter Value: This specifies a criterion based on which the window selects a subset of events to be processed. Multiple parameters can be added by clicking +Attribute.
    Info

    A Siddhi application can have multiple stream handlers. To add another stream handler, click the + Stream Handler. Multiple functions, filters and windows can be defined within the same form as stream handlers.

Example

The details entered in the above Query Configuration form creates a query definition with a window as follows:

Code Block
languagesql
from TradeStream#window.time(1 month)
select symbol, avg(price) as averagePrice, sum(amount) as total
insert all events into OutputStream;
Source
Info

A window query can have only one source at a given time.

  • Streams
  • Tables
  • Triggers
  • Windows
Target
  • Streams
  • Tables
  • Windows

...

Icon

DescriptionA join query derives a combined result from two streams in real-time based on a specified condition. For more information, see Siddhi Query Guide - Join.
Form

Once you connect two Siddhi components to the join query as sources and another Siddhi component as the target, move the cursor over the join query and click the settings icon on the projection query (shown below) to open the Join Query Configuration form.

The following information needs to be entered in this form:

Configurations common for both sources

  • Select: This section specifies the attributes to be included in the output. In the Select field, you can select All Attributes to select all the attributes of the events, or select User Defined Attributes to select specific attributes, and the expressions to convert them as required to generate output events.
  • Output: This section specifies the action to be performed on the output event. The fields to be configured in this section are as follows:
    • Operation: This field specifies the operation to be performed on the generated output event (e.g., Insert to insert events to a selected stream/table/window).
    • Into: This field specifies the stream/table/window in which the operation specified need to be performed.
    • For: This field specifies whether the operation needs to be performed for all output events, only current events or for only expired events.

The stream handlers need to be separateley configured for the left source and the right source of the join.

Configurations for each source

The following configurationsare entered under Left Source and Right Source.

  • Input: Thes section specifies the input. This can be a stream, aggregation, window or a table for each source.
  • Stream Handlers: This section defines the functions, filters, and windows that can be included in the query to extract events from the left/right source.
Example

A join query is configured as follows:

  • Common configurations
    Image Removed
  • Left source configuration
    Image Removed
     
  • Right source configuration
    Image Removed 

The above configurations result in creating the following join query.Image Added

The details entered in the above form creates a query definition with a join as follows:

Code Block
languagesql
from TempStream[temp > 30.0]#window.time(1 min) as T
  join RegulatorStream[isOn == false]#window.length(1) as R
  on T.roomNo == R.roomNo
select T.roomNo, R.deviceID, 'start' as action
insert into RegulatorActionStream;
Source
Info

A join query must always be connected to two sources, and at least one of them must be a defined stream/trigger/window.

  • Streams
  • Tables
  • Aggregations
  • Windows
Target
Info

A join query must always be connected to a single target.

  • Streams
  • Tables
  • Windows

Pattern Query

Icon

Image RemovedImage Added

Description
Tip
iconfalse
titleBefore you add a pattern query:

You need to add and configure the following:

  • The input stream with the events to be processed by the query.
  • The output stream to which the events processed by the query are directed.

A pattern query detects patterns in events that arrive overtime. For more information, see Siddhi Query Guide - Patterns.

Form

Once you connect the query to an input stream (source) and an output stream (target), move the cursor over the query and click the settings icon on the pattern query component (shown below) to open the Pattern Query Configuration form.

The following information is configured in the Pattern Query Configuration form:

  • Name: This field specifies a unique name for the pattern query.
  • Annotations: One or more annotations to be included in the pattern query can be entered in this section. To expand this section to add annotations, click Properties and select the Add Annotations check box. As a result, a single field appears to add an annotation as shown below. To add more annotation fields, click + Annotation.

  • Input: This section displays the input streams that are currently connected to the pattern query as sources.
  • Conditions: This section defines the conditions based on which patterns are identified. This involves specifying a unique ID and the input stream considered for each condition. Multiple conditions can be added. To add a new condition, click +Condition.
  • Logic: This section defines the detailed logic based on which the pattern query output is generated.
Example

Image RemovedImage Added

The above configuration results details entered in creating the following query.above form creates a query definition with a pattern as follows:

Code Block
languagesql
from every (e1 =MaterialSupplyStream) RegulatorStream -> note2 MaterialConsumptionStream[name == TempStream[e1.name androomNo amount == e1.amountroomNo] < 1: > ->  for 15 sece3 = RegulatorStream[e1.roomNo == roomNo] 
select e1.name, e1.amountroomNo as roomNo, e2[0].temp - e2[last].temp as tempDiff 
insert into ProductionDelayAlertStreamTempDiffStream;
Source
  • Streams
  • Tables
  • Triggers
  • Windows
Target
  • Streams
  • Tables
  • Windows


Sequence Query

Icon

Image RemovedImage Added

Description
Tip
iconfalse
titleBefore you add a sequence query:

You need to add and configure the following:

  • The input stream with the events to be processed by the query.
  • The output stream to which the events processed by the query are directed.

A sequence query detects sequences in event occurrences over time. For more information, see Siddhi Query Guide - Sequence.

Form

Once you connect the query to an input stream (source) and an output stream (target), move the cursor over the query and click the settings icon on the sequence query component (shown below) to open the Sequence Query Configuration form.

The following information is configured in the Sequence Query Configuration form:

  • Name: This field specifies a unique name for the sequence query.
  • Annotations: One or more annotations to be included in the sequence query can be entered in this section. To expand this section to add annotations, click Properties and select the Add Annotations check box. As a result, a single field appears to add an annotation as shown below. To add more annotation fields, click + Annotation.
  • Input: This section displays the input streams that are currently connected to the sequence query as sources.
  • Conditions: This section defines the conditions based on which sequences are identified. This involves specifying a unique ID and the input stream considered for each condition. Multiple conditions can be added. To add a new condition, click +Condition.
  • Logic: This section defines the detailed logic based on which the sequence query output is generated.
Example

Image RemovedImage Added

The above configuration results details entered in creating the following query.above form creates a query definition with a sequence as follows:

Code Block
languagesql
from every e1 = SweetProductionStreamRegulatorStream , e2 = SweetProductionStream[e1.amount > amountTempStream and (timestamp - e1.timestamp) < 10 * 60000]* , e3 = SweetProductionStream[timestamp - e1.timestamp > 10 * 60000 and e1.amount > amount] 
select e1.name as name, e1.amount as initialAmount, e2.amount as finalAmount, e2.timestamp as timestampHumidStream 
select e2.temp as temp, e3.humid as humid 
insert into DecreasingTrendAlertStreamStateNotificationStream;
Source
  • Streams
  • Tables
  • Triggers
  • Windows
Target
  • Streams
  • Tables
  • Windows

...

Icon

Description
Tip
titleBefore you add a partition:

You need to add the stream to be partitioned.

Partitions divide streams and queries into isolated groups in order to process them in parallel and in isolation. For more information, see Siddhi Query Guide - Partition.

Form

Once the stream to be partitioned is connected as a source to the partition, move the cursor over the partition and click the settings icon to open the Partition form.

In this form, you can enter expressions to convert the attributes of the stream selected to be partitioned, to create output events.

Example

Image RemovedImage Added

The above configuration creates the following partition query.

Code Block
languagesql
partition with ( roomNo >= 1030 as 'serverRoom' or 
                 roomNo < 1030 and roomNo >= 330 as 'officeRoom' or 
                 roomNo < 330 as 'lobby' of TempStream)
begin
    from TempStream#window.time(10 min)
    select roomNo, deviceID, avg(temp) as avgTemp
    insert into AreaTempStream
end;
SourceStreams
TargetN/A

...