The Siddhi Language consists of following constructs.
- Event Stream Definitions
- Event Table Definitions
- Partition Definitions
- Queries
- Calls to external functions (not supported in 1.0)
Following provides an abstract BNF based definition for Siddhi language.
<execution-plan> ::= <define-parition> | <define-stream> | <define-table> | <execution-query>
<define-partition> ::= define partition <partition-id> by <partition-type> {, <partition-type>}
<define-stream> ::= define stream <stream-name> <attribute-name> <type> {<attribute-name> <type>}
<define-table> ::= define table <table-id> ( <attribute-name> <type> {, <attribute-name> <type>} ) { from <table-type>.<datasource-name>:<database-name>.<table-name>}
<execution-query>::= <input> <output> [<projection>]
<input> ::= from <streams>
<output> ::= ((insert [<output-type>] into <stream-name>) | (return [<output-type>]))
<streams> ::= <stream>[#<window>]
| <stream>#<window> [unidirectional] <join> [unidirectional] <stream>#<window> on <condition> within <time>
| [every] <stream> -> <stream> ... <stream> within <time>
| <stream>, <stream>, <stream> within <time>
<stream> ::= <stream-name> <condition-list>
<projection> ::= (<external-call> <attributelist>) | <attributelist> [group by <attribute-name> ][having <condition>]
<external-call> ::= call <name> ( <param-list> )
<condition-list> ::= {‘[’<condition>’]’}
<attributelist>::=(<attribute-name> [as <reference-name>]) | ( <function>(<param-list>) as <reference-name>)
<output-type> ::= expired-events | current-events | all-events
<param-list> ::= {<expression>}
<condition> ::= ( <condition> (and|or) <condition> ) | (not <condition>) | ( <expression> (==|!=|>=|<=|>|<|contains|instanceof) <expression> )
<expression> ::= ( <expression> (+ | - | / | * | %) <expression> ) | <attribute-name> | <int> | <long> | <double> | <float> | <string> | <time>
<time> ::= [<int>( years | year )] [<int>( months | month )] [<int>( weeks | week )] [<int>( days | day )] [<int>( hours | hour )] [<int>( minutes | min | minute )] [<int>( seconds | second | sec )]
[<int>( milliseconds | millisecond )]