Versions Compared

Key

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

Siddhi Inbuilt functions in wiki format

Following are the supported inbuilt functions of Siddhi

Excerpt

Table of Contents

coalesce
Anchor
coalesce
coalesce

< int|long|float|double|string|bool|object > coalesce (<int|long|float|double|string|bool|object >  arg1<int|long|float|double|string|bool|object > arg2,.., <int|long|float|double|string|bool|object > argN)

  • Extension TypeFunction 
  • Description: Returns the value of the first non null input parameter.
  • Parameters: This function accepts one or more parameters, and they all have to be the same type of, any one of the available types.
  • Return Type: Return type will be the first input parameter's type.
  • Examplescoalesce('123', null, '789') returns '123'. coalesce(null, 76, 567) returns 76. coalesce(null, null, null) returns null. 

convert
Anchor
convert
convert

< int|long|float|double|string|bool > convert (<int|long|float|double|string|bool>  toBeConverted<string> convertedTo)

  • Extension TypeFunction 
  • Description: Converts the first input parameter according to the convertedTo parameter. 
  • Parameter: toBeConverted : To be converted parameter with type other than object.
  • Parameter: convertedTo : A string constant parameter expressing the everted to type using one of the following strings values: 'int', 'long', 'float', 'double', 'string', 'bool'.
  • Return Type: Return type will be type specified by the convertedTo parameter.
  • Examplesconvert('123', 'double') returns 123.0. convert(45.9, 'int') returns 46. convert(true, 'string') returns 'true'. 

instanceOfBoolean
Anchor
boolean
boolean

< bool > instanceOfBoolean (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Boolean or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Boolean and false otherwise.
  • ExamplesinstanceOfBoolean(123) returns false. instanceOfBoolean(true) returns true. instanceOfBoolean(false) returns true. 

instanceOfDouble
Anchor
double
double

< bool > instanceOfDouble (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Double or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Double and false otherwise.
  • ExamplesinstanceOfDouble(123) returns false. instanceOfDouble(56.45) returns true. instanceOfDouble(false) returns false. 

instanceOfFloat
Anchor
float
float

< bool > instanceOfFloat (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Float or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Float and false otherwise.
  • ExamplesinstanceOfFloat(123) returns false. instanceOfFloat(56.45) returns false. instanceOfFloat(56.45f) returns true. 

instanceOfInteger
Anchor
integer
integer

< bool > instanceOfInteger (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Integer or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Integer and false otherwise.
  • ExamplesinstanceOfInteger(123) returns true. instanceOfInteger(56.45) returns false. instanceOfInteger(56.45f) returns false. 

instanceOfLong
Anchor
long
long

< bool > instanceOfLong (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Long or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Long and false otherwise.
  • ExamplesinstanceOfLong(123) returns false. instanceOfLong(5667l) returns true. instanceOfLong(56.67) returns false. 

instanceOfString
Anchor
string
string

< bool > instanceOfString (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of String or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of String and false otherwise.
  • ExamplesinstanceOfString('test') returns true. instanceOfString('5667') returns true. instanceOfString(56.67) returns false. 

UUID

< string > UUID ( )

  • Extension TypeFunction 
  • Description: Generate a UUID. 
  • Return Type: Returns a UUID string.
  • ExamplesUUID() returns a34eec40-32c2-44fe-8075-7f4fde2e2dd8. 

E.g. Converting room number to string and introducing message ID to each event

Code Block
languagesql
linenumberstrue
from TempStream 
select convert(roomNo, 'string') as roomNo, temp, UUID() as messageID
insert into RoomTempStream;