Versions Compared

Key

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

...

The following functions shipped with Siddhi, consume zero, one or more parameters from streaming events and produce a desired value as output. These functions are executed per event. For more information on Siddhi functions, please refer to Siddhi Query Guide - Functions. More functions are made available as Siddhi Extensions.

  • eventTimestamp - Returns the timestamp of the processed event

    Code Block
    languagesql
    titleeventTimeStamp example
    from fooStream
    select symbol as name, eventTimestamp() as eventTimestamp
    insert into barStream
  • UUID - Generates a UUID (Universally Unique Identifier)

    Code Block
    languagesql
    titleUUID example
    from fooStream
    select UUID() as messageID, messageDetails
    insert into barStream;
  • default - Checks if the 'attribute' parameter is null and if so returns the value of the 'default' parameter. The function is given as default(<attribute>, <default value>)

    Code Block
    languagesql
    titledefault example
    from fooStream
    select default(temp, 0.0) as temp, roomNum
    insert into barStream;
  • cast - Converts the first parameter according to the cast-to parameter. Incompatible arguments cause Class Cast exceptions if further processed.

    Code Block
    languagesql
    titlecast example
    from fooStream
    select symbol as name, cast(temp, 'double') as temp
    insert into barStream;
  • convert - Converts the first input parameter according to the convert-to parameter

    Code Block
    languagesql
    titleconvert example
    from fooStream
    select convert(temp, 'double') as temp
    insert into barStream;
  • ifThenElse - Evaluates the 'condition' parameter and returns value of the 'if.expression' parameter if the condition is true, or returns value of the 'else.expression' parameter if the condition is false. The function is given as ifThenElse(<condition>, <if.expression>, <else.expression>)

    Code Block
    languagesql
    titleifThenElse example
    from fooStream
    ifThenElse(sensorValue>35,'High','Low')
    insert into barStream;
  • minimum - Returns the minimum value of the input parameters

    Code Block
    languagesql
    titleminimum example
    from fooStream
    select minimum(price1, price2, price3) as minPrice
    insert into barStream;
  • maximum - Returns the maximum value of the input parameters. This function could be used similar to how 'minimum' function is used in a query.
  • coalesce - Returns the value of the first input parameter that is not null. All input parameters have to be of the same type.

    Code Block
    languagesql
    titlecoalesce example
    from fooStream
    select coalesce('123', null, '789') as value
    insert into barStream;
  • instanceOfBoolean - Returns 'true' if the input is a instance of Boolean. Otherwise returns 'false'. 

    Code Block
    languagesql
    titleinstanceOfBoolean example
    from fooStream
    select instanceOfBoolean(switchState) as state
    insert into barStream;
  • instanceOfDouble - Returns 'true'  if the input is a instance of Double. Otherwise returns 'false'. This function could be used similar to how 'instanceOfBoolean' function is used in a query.
  • instanceOfFloat - Returns 'true'  if the input is a instance of Float. Otherwise returns 'false'. This function could be used similar to how 'instanceOfBoolean' function is used in a query.
  • instanceOfInteger - Returns 'true'  if the input is a instance of Integer. Otherwise returns 'false'. This function could be used similar to how 'instanceOfBoolean' function is used in a query.
  • instanceOfLong - Returns 'true'  if the input is a instance of Long. Otherwise returns 'false'. This function could be used similar to how 'instanceOfBoolean' function is used in a query.
  • instanceOfString - Returns 'true'  if the input is a instance of String. Otherwise returns 'false'. This function could be used similar to how 'instanceOfBoolean' function is used in a query.

...

Filters are applied to input data received in streams to filter information based on given conditions. For more information, see Siddhi Query Guide - Filters.

e.g., Filtering cash withdrawals from an ATM machine where the withdrawal amount is greater tha $100, and the withdrawal data is between 01/12/2017-15/12/2017.

...

  • Events 1-5
  • Events 2-6
  • Events 3-7
  • Events 4-8
  • Events 5-9
  • Events 6-10

When a batch window is included in a Siddhi query, the folowing event groups are identified:

...

This window feature differs from the Defined Window concept elaborated here due to this being specific to a single query only. If a window is to be shared among queries, the Defined Window must be used

For more information about windows, see Siddhi Query Guide - Window.

Aggregate Functions

Aggregation functions allow executing aggregations such as sum, avg, min, etc. on a set of events grouped by a window. If a window is not defined, the aggregation(s) would be calculated by considering all the events arriving at a stream. 

...

For more information on aggregate function, please refer to Siddhi Query Guide - Aggregate Functions.

Group By

With the group by  functionality, events could be grouped based on a certain attribute, when performing aggregations. 

...

For more information on group by, please refer to Siddhi Query Guide - Group By.

Having

Having allows to filter events after processing the select statement.

...

For more information on having clause, please refer to Siddhi Query Guide - Having.

Join

Join is an important feature of Siddhi, which allows combining pair of streams, pair of windows, stream with window, stream/ window with a table and stream/window with an aggregation

...

For more information on join queries, please refer to Siddhi Query Guide - Join.

Output Rate Limiting

Output rate limiting allows queries to output events periodically based on a specified condition. This helps to limit continuously sending events as output.

For more information on output rate limiting, please refer to Siddhi Query Guide - Output Rate Limiting 

Partitioning

Partitioning in Siddhi allows to logically seperate events arriving at a stream, and to process them separately, in parallel.

...

Partitioning can be done based on an attribute value as above, or based on a condition. For more information on partitioning, please refer to Siddhi Query Guide - Partitioning 

Trigger

Triggers could be used to get events generated by the system itself, based on some time duration.

...

Trigger could be defined as a time interval, a cron job or to generate an event when Siddhi is started. For more information on triggers, please refer to Siddhi Query Guide - Trigger

Script

Scripts allow to define function operations in a different programming language. An example is as follows.

...

For more information on scripts, please refer to Siddhi Query Guide - Script