RAQL Query Syntax Reference
This topic contains syntax definitions and corresponding syntax diagrams for the Real-Time Analytics Query Language (RAQL) in Presto and the Event Query Language (EQL) for the webMethods Event Server. Some keywords or specific syntax constructions are relevant only in RAQL while others are relevant only in EQL.
See the following links to find the start of definitions for the valid clauses in RAQL:
For RAQL | Definition Begins From |
Entire query | |
Select clause | |
Over partitions | |
From Clause | |
Join and other set operators | |
Where clause | |
Group by clause | |
Having clause | |
Order by clause | |
Limit clause | |
Action (EQL only)
Applies only to EQL queries in webMethods Business Events.
Alias
Definition:
Alias
::= 'AS'? ObjectName
Used In:
MatchingClause SelectItem SourceReferenceOrSubquery Array Element Reference
Definition:
ArrayElementReference
::= '[' S_NUMBER ']'
Used In:
SqlPrimaryExpression Array Value Constructor
Definition:
ArrayValueConstructor
::= 'ARRAY' '[' SqlExpressionList ']'
Used In:
SqlPrimaryExpression Between Condition
Definition:
SqlBetweenClause
::= 'NOT'? 'BETWEEN' SqlSimpleExpression 'AND'
SqlSimpleExpression
Used In:
SqlRelationalExpression Case Call, Boolean
Definition:
BooleanCaseCall
::= ( 'WHEN' SqlExpression
'THEN' SqlSimpleExpression )+
( 'ELSE' SqlSimpleExpression )? 'END'
Used In:
FunctionCall Case Call, Simple
Definition:
SimpleCaseCall
::= SqlSimpleExpression
( 'WHEN' SqlSimpleExpression
'THEN' SqlSimpleExpression )+
( 'ELSE' SqlSimpleExpression )? 'END'
Used In:
FunctionCall Character, Literal
Definition:
S_CHAR_LITERAL
::= "'" ( "'" "'" | [^'] )* "'"
Used In:
Constant MatchingClause MeasureItem WindowClauseEQL Constant
Definition:
Constant
::= 'NULL'
| ( '+' | '-' )? S_NUMBER
| S_CHAR_LITERAL
| 'TRUE'
| 'FALSE'
Used In:
ConstantList SqlPrimaryExpression WindowFunctionCall Constant, List
Definition:
ConstantList
::= Constant ( ',' Constant )*
Used In:
Data Type, Basic Declaration (EQL only)
Applies only to EQL queries in webMethods Business Events.
Data Type, Castable
RAQL has minimal, passive support for the following datatypes.
Blob
Clob
Ref
Struct
Dataset columns may contain data of these types, but RAQL provides no access to read or manipulate this data.
Definition:
CastableDataTypeDeclaration
::= ( 'BIG_DECIMAL'
| 'BYTE'
| 'INTEGER'
| 'FLOAT'
| 'LONG'
| 'SHORT'
| 'DOUBLE'
| 'CHARACTER'
| 'STRING'
| 'DATE'
| 'TIMESTAMP'
| 'TIME'
| 'BOOLEAN'
| 'BLOB'
| 'CLOB'
| 'REF'
| 'STRUCT'
| 'UNKNOWN' ) 'ARRAY'?
Used In:
FunctionCall Define Clause (EQL only)
Applies only to EQL queries in webMethods Business Events.
Define Item (EQL only)
Applies only to EQL queries in webMethods Business Events.
DIGIT
Definition:
DIGIT
::= [0-9]
Used In:
INTEGER EOF: End of File
This character is not actually specified in a query by users as the EOF character is illegal in XML. Instead, this character is automatically added by the parser for validation purposes.
Definition:
EOF
::= $
Used In:
SelectStatement Field Definition (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Field Definition List (EQL Only)
Applies only to EQL queries in webMethods Business Events.
FLOAT
Definition:
FLOAT
::= INTEGER ( '.' INTEGER )?
| '.' INTEGER
Used In:
S_NUMBER Frame Boundary (RAQL Only)
Definition:
FrameBound
::= S_NUMBER
Used In:
WindowFrameBound WindowFrameStart From Clause
Definition:
FromClause
::= 'FROM' FromItem ( ',' FromItem )*
Used In:
SelectWithoutOrder From Item
Definition:
FromItem
::= SourceReferenceOrSubquery JoinedTable*
Used In:
FromClause Function Call
This section diagrams only those plain functions that are built into RAQL which RAQL supports from the SQL standard.
For additional diagrams on other built-in and user defined functions in
RAQL, see
Function Call, Aggregate,
Function Call, Window (RAQL Only) and
Function Call, Generic. For a complete list and reference information of all plain and analytic functions in
RAQL, see
Built-In
RAQL
Functions.
Definition:
FunctionCall
::= 'ABS' '(' SqlExpression ')'
| 'CASE' ( SimpleCaseCall | BooleanCaseCall )
| 'CAST' '(' SqlExpression 'AS' CastableDataTypeDeclaration ')'
| ( 'CEIL' | 'CEILING' ) '(' SqlExpression ')'
| ( 'CHAR_LENGTH' | 'CHARACTER_LENGTH' ) '(' SqlExpression ')'
| 'EXP' '(' SqlExpression ')'
| 'FLOOR' '(' SqlExpression ')'
| 'LN' '(' SqlExpression ')'
| 'LOWER' '(' SqlExpression ')'
| 'MOD' '(' SqlExpression ',' SqlExpression ')'
| 'POWER' '(' SqlExpression ',' SqlExpression ')'
| 'ROUND' '(' SqlExpression ( ',' SqlExpression )? ')'
| 'SQRT' '(' SqlExpression ')'
| 'SUBSTRING' '(' SqlExpression 'FROM' SqlExpression ( 'FOR' SqlExpression )? ')'
| 'TRIM' '(' ( ( 'LEADING' | 'TRAILING' | 'BOTH' )? SqlExpression? 'FROM' )? SqlExpression ')'
| ( 'TRUNC' | 'TRUNCATE' ) '(' SqlExpression ( ',' SqlExpression )? ')'
| 'UPPER' '(' SqlExpression ')'
Used In:
SqlPrimaryExpression Function Call, Aggregate
This section diagrams only those aggregate analytic functions that are built into RAQL which RAQL supports from the SQL standard.
For additional diagrams on other built-in and user defined functions in
RAQL, see
Function Call,
Function Call, Window (RAQL Only) and
Function Call, Generic. For a complete list and reference information of all plain and analytic functions in
RAQL, see
Built-In
RAQL
Functions.
Definition:
AggregateFunctionCall
::= ( 'AVG'
| 'MAX'
| 'MIN'
| 'STDDEV_POP'
| ( 'STDDEV' | 'STDDEV_SAMP' )
| 'SUM'
| 'VAR_POP'
| ( 'VARIANCE' | 'VAR_SAMP' )
)
'(' ( ( 'ALL' | 'DISTINCT' ) SourceField | SqlExpression ) ')'
| 'COUNT' '(' ( '*' | ( 'ALL' | 'DISTINCT' ) SourceField | SqlExpression ) ')'
| ( 'CORR'
| 'COVAR_POP'
| ( 'COVAR_SAMP' | 'COVAR' )
| 'REGR_INTERCEPT'
| 'REGR_R2'
| 'REGR_SLOPE' ) '(' ( SqlExpression | SourceField ) ','
( SqlExpression | SourceField ) ')'
Used In:
SqlPrimaryExpression Function Call, Window (RAQL Only)
This section diagrams only those window analytic functions that are built into RAQL which RAQL supports from the SQL standard.
For additional diagrams on other built-in and user defined functions in
RAQL, see
Function Call,
Function Call, Aggregate and
Function Call, Generic. For a complete list and reference information of all plain and analytic functions in
RAQL, see
Built-In
RAQL
Functions.
Definition:
WindowFunctionCall
::= ( 'RANK'
| 'DENSE_RANK'
| 'PERCENT_RANK'
| 'CUME_DIST'
| 'ROW_NUMBER' ) '(' ')' WindowClauseRAQL
| 'NTILE' '(' S_NUMBER ')' WindowClauseRAQL
| ( 'LEAD' | 'LAG' ) '('
( SqlExpression | SourceField ) ( ',' S_NUMBER ( ',' Constant )? )? ')' WindowClauseRAQL
| ( 'FIRST_VALUE'
| 'LAST_VALUE' ) '(' ( SqlExpression | SourceField ) ( ',' Constant )? ')' WindowClauseRAQL
| 'NTH_VALUE' '(' ( SqlExpression | SourceField ) ',' S_NUMBER ( ',' Constant )? ')' WindowClauseRAQL
Used In:
SqlPrimaryExpression Function Call, Generic
built-in functions not covered in sql + user-defined functions
Definition:
GenericFunctionCall
::= ObjectName '(' SqlExpressionList?
( ';' ConstantList )? ')'
Used In:
SqlPrimaryExpression Group By Clause
Definition:
GroupByClause
::= 'GROUP' 'BY' SqlExpressionList
Used In:
SelectWithoutOrder Having Clause
Definition:
HavingClause
::= 'HAVING' ( SetCondition | SqlExpression )
Used In:
SelectWithoutOrder S_IDENTIFIER
Definition:
S_IDENTIFIER
::= NAMESTARTCHAR NAMECHAR*
Used In:
DefineItem ObjectName S_UDO_IDENTIFIER S_ QUOTED_IDENTIFIER
Definition:
S_QUOTED_IDENTIFIER
::= '"' [^#x000A#x000D"]* '"'
Used In:
ObjectName In Condition
Definition:
SqlInClause
::= 'NOT'? 'IN' '(' SqlExpressionList ')'
Used In:
SqlRelationalExpression INTEGER
Definition:
INTEGER ::= DIGIT+
Used In:
FLOAT S_NUMBER Is Null Condition
Definition:
IsNullClause
::= 'IS' 'NOT'? 'NULL'
Used In:
SqlRelationalExpression Join Clause
Definition:
JoinedTable
::= 'CROSS' 'JOIN' SourceReferenceOrSubquery
| 'NATURAL' 'INNER'? 'JOIN' SourceReferenceOrSubquery
| 'INNER'? 'JOIN' SourceReferenceOrSubquery
( 'ON' SqlExpression
| 'USING' '(' SourceFieldList ')' )?
Used In:
FromItem Like Condition
Definition:
SqlLikeClause
::= 'NOT'? 'LIKE' SqlSimpleExpression
Used In:
SqlRelationalExpression Limit Clause (RAQL Only)
Definition:
LimitClause
::= 'LIMIT' S_NUMBER ( ',' S_NUMBER )?
Used In:
SelectWithOrder Matching Clause (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Measure Clause (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Measure Item (EQL Only)
Applies only to EQL queries in webMethods Business Events.
NAMECHAR
Definition:
NAMECHAR ::= NAMESTARTCHAR
| [$0-9#x00B7#x0300-#x036F#x203F-#x2040]
Used In:
S_IDENTIFIER NAMESTARTCHAR
Definition:
NAMESTARTCHAR
::= [:A-Z_a-z#x00C0-#x00D6#x00D8-#x00F6#x00F8-#x02FF#x0370-#x037D#x037F-#x1FFF#x200C-#x200D#x2070-#x218F#x2C00-#x2FEF#x3001-#xD7FF#xF900-#xFDCF#xFDF0-#xFFFD]
Used In:
NAMECHAR S_IDENTIFIER S_NUMBER
Definition:
S_NUMBER ::= FLOAT ( [eE] [-+]? INTEGER )?
Used In:
ArrayElementReference Constant FrameBound LimitClause MeasureItem SetCondition ShiftClause WindowClauseEQL WindowFunctionCall Object Name
Definition:
ObjectName
::= S_IDENTIFIER | S_QUOTED_IDENTIFIER
Used In:
Action Alias FieldDefinition GenericFunctionCall MeasureItem SelectStar SourceField SourceReference SqlPrimaryExpression WithClause Order By Clause (RAQL Only)
Definition:
OrderByClause
::= 'ORDER' 'BY' SqlExpression
( 'ASC' | 'DESC' )?
( 'NULLS' ( 'FIRST' | 'LAST' ) )?
( ',' SqlExpression ( 'ASC' | 'DESC' )?
( 'NULLS' ( 'FIRST' | 'LAST' ) )? )*
Used In:
SelectWithOrder WindowClauseRAQL Query Expression Body
Definition:
QueryExpressionBody
::= QueryTerm
( ( 'UNION' | 'EXCEPT' | 'MINUS' )
( 'ALL' | 'DISTINCT' )? QueryTerm )*
Used In:
QueryPrimary SelectWithOrder SqlRelationalOperatorExpression Query Primary
Definition:
QueryPrimary
::= SelectWithoutOrder | '(' QueryExpressionBody ')'
Used In:
QueryTerm Query Term
Definition:
QueryTerm
::= QueryPrimary ( 'INTERSECT' ( 'ALL' | 'DISTINCT' )?
QueryPrimary )*
Used In:
QueryExpressionBody Relational Operators
Definition:
Relop ::= '='
| '!='
| '#'
| '<>'
| '>'
| '>='
| '<'
| '<='
Used In:
SqlRelationalOperatorExpression Select Item
Definition:
SelectItem
::= '*' | SelectStar | SqlSimpleExpression Alias?
Used In:
SelectList Select List
Definition:
SelectList
::= SelectItem ( ',' SelectItem )*
Used In:
SelectWithoutOrder Select Wildcard
Definition:
SelectStar
::= ObjectName '.' ( ObjectName '.' )? '*'
Used In:
SelectItem Select Statement
Definition:
SelectStatement
::= WithClause? SelectWithOrder ';'? EOF
Used In:
This is the starting definition of RAQL queries, which has no parent references.
Select With Order
Definition:
SelectWithOrder
::= QueryExpressionBody OrderByClause? LimitClause?
Used In:
SelectStatement SourceReferenceOrSubquery WithClause Select Without Order
Definition:
SelectWithoutOrder
::= 'SELECT' ( 'ALL' | 'DISTINCT' )? SelectList FromClause WhereClause? GroupByClause? HavingClause?
Used In:
QueryPrimary Set Condition (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Set Condition, Multiple Field (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Set Condition, Single Field (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Shift Clause (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Source Field
Definition:
SourceField
::= ObjectName ( '.' ObjectName ( '.' ObjectName )? )?
Used In:
AggregateFunctionCall SingleFieldSetCondition SourceFieldList WindowFunctionCall Source Field List
Definition:
SourceFieldList
::= SourceField ( ',' SourceField )*
Used In:
JoinedTable MatchingClause MultipleFieldSetCondition WindowClauseEQL Source Reference
Definition:
SourceReference
::= ObjectName ( '.' ObjectName )?
( '/' ObjectName ( '.' ObjectName )? )+
| UserDefinedOperator
| ObjectName ( '.'
( UserDefinedOperator | ObjectName ) )?
Used In:
SourceReferenceList SourceReferenceOrSubquery Source Reference List (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Source Reference or Subquery
Definition:
SourceReferenceOrSubquery
::= SourceReference TemporalClause Alias? MatchingClause?
| '(' SelectWithOrder ')' TemporalClause Alias? MatchingClause?
Used In:
FromItem JoinedTable SQL Expresssion
Definition:
SqlExpression
::= SqlAndExpression ( 'OR' SqlAndExpression )*
Used In:
AggregateFunctionCall BooleanCaseCall DefineItem FunctionCall HavingClause JoinedTable OrderByClause SqlExpressionList SqlPrimaryExpression WhereClause WindowFunctionCall SQL Expression, And
Definition:
SqlAndExpression
::= SqlUnaryLogicalExpression ( 'AND' SqlUnaryLogicalExpression )*
Used In:
SqlExpression SQL Expression, Exponent
Definition:
SqlExponentExpression
::= SqlUnaryExpression ( '**' SqlUnaryExpression )*
Used In:
SqlMultiplicativeExpression SQL Expression, List
Definition:
SqlExpressionList
::= SqlExpression ( ',' SqlExpression )*
Used In:
ArrayValueConstructor GenericFunctionCall GroupByClause SqlInClause SqlRelationalExpression WindowClauseRAQL SQL Expression, Multiplicative
Definition:
SqlMultiplicativeExpression
::= SqlExponentExpression ( ( '*' | '/' | '%' ) SqlExponentExpression )*
Used In:
SqlSimpleExpression Sql Expression, Primary
Definition:
SqlPrimaryExpression
::= '(' SqlExpression ')'
| Constant
| FunctionCall
| AggregateFunctionCall WindowClauseRAQL?
| WindowFunctionCall
| GenericFunctionCall WindowClauseRAQL?
| ObjectName ( '.'
( GenericFunctionCall WindowClauseRAQL?
| ObjectName
( '.' ObjectName ArrayElementReference?
| ArrayElementReference )? )
| ArrayElementReference )?
| ArrayValueConstructor
Used In:
SqlUnaryExpression SQL Expression, Relational
Definition:
SqlRelationalExpression
::= ( '(' SqlExpressionList ')' | SqlSimpleExpression ) ( SqlRelationalOperatorExpression | SqlInClause | SqlBetweenClause | SqlLikeClause | IsNullClause )?
Used In:
SqlUnaryLogicalExpression SQL Expression, Relational Operators
Definition:
SqlRelationalOperatorExpression
::= RelOp ( '(' QueryExpressionBody ')' | SqlSimpleExpression )
Used In:
SqlRelationalExpression SQL Expression, Simple
Definition:
SqlSimpleExpression
::= SqlMultiplicativeExpression ( ( '+' | '-' | '||' ) SqlMultiplicativeExpression )*
Used In:
Action BooleanCaseCall MatchingClause SelectItem SimpleCaseCall SqlBetweenClause SqlLikeClause SqlRelationalExpression SqlRelationalOperatorExpression WindowClauseEQL SQL Expression, Unary
Definition:
SqlUnaryExpression
::= SqlPrimaryExpression
| ( '+' | '-' ) SqlPrimaryExpression
| SqlPrimaryExpression
Used In:
SqlExponentExpression SQL Expression, Unary Logical
Definition:
SqlUnaryLogicalExpression
::= 'NOT'? SqlRelationalExpression
Used In:
SqlAndExpression Temporal Clause (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Time Unit, Constant (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Time Unit, Nonconstant (EQL Only)
Applies only to EQL queries in webMethods Business Events.
S_UDO_IDENTIFIER
Applies only to EQL queries in webMethods Business Events.
User Defined Operator (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Where Clause
Definition:
WhereClause
::= 'WHERE' SqlExpression
Used In:
SelectWithoutOrder White Space and Other Ignorable Characters
The parser also ignores common white space characters such as space or line ends, along with comment lines that use the single-line or multi-line formats.
Definition:
Ignorable white space
::= ' '
| #x0009
| #x000D
| #x000A
| Single-line-comment
| Multi-line-comment
Single-line-comment
::= '--' [^#x000D#x000A]*
Multi-line-comment
::= '/' '*' ( [^*] | '*'+ [^*/] )* '*'+ '/'
Window Clause (EQL Only)
Applies only to EQL queries in webMethods Business Events.
Window Clause (RAQL Only)
Definition:
WindowClauseRAQL
::= 'OVER' '(' ( 'PARTITION' 'BY' SqlExpressionList )?
OrderByClause? WindowFrameClause? ')'
Used In:
SqlPrimaryExpression WindowFunctionCall Window Frame Boundary (RAQL Only)
Definition:
WindowFrameBound
::= ( 'UNBOUNDED' | FrameBound ) 'FOLLOWING'
| WindowFrameStart
Used In:
WindowFrameClause Window Frame Clause (RAQL Only)
Definition:
WindowFrameClause
::= ( 'ROWS' | 'RANGE' ) ( WindowFrameStart | 'BETWEEN' WindowFrameBound 'AND' WindowFrameBound )
Used In:
WindowClauseRAQL Window Frame Start (RAQL Only)
Definition:
WindowFrameStart
::= ( 'UNBOUNDED' | FrameBound ) 'PRECEDING'
| 'CURRENT' 'ROW'
Used In:
WindowFrameBound WindowFrameClause With Clause
Applies only to EQL queries in webMethods Business Events.