TimeBase Query Language reference
Click Tag to Display Pages: development tools

Reserved Keywords

QQL is grammatically and stylistically similar to Standard SQL.

The following keywords are reserved and cannot be used as identifiers, unless enclosed in double-quotes.

  • ALTER
  • AND
  • ARRAY
  • AS
  • BETWEEN
  • BY
  • CAST
  • CLASS
  • COMMENT
  • CONFIRM
  • CREATE
  • DEFAULT
  • DISTINCT
  • DROP
  • DURABLE
  • ENUM
  • FALSE
  • FLAGS
  • FROM
  • GROUP
  • IN
  • INSTANTIABLE
  • IS
  • LIKE
  • MODIFY
  • NEW
  • NOT
  • NULL
  • OBJECT
  • OPTIONS
  • OR
  • RELATIVE
  • RUNNING
  • SELECT
  • STATIC
  • STREAM
  • TO
  • TRANSIENT
  • TRUE
  • UNDER
  • UNION
  • WHERE

QQL Grammar

<Clause> ::=
A QQL program is either a data definition statement, or a query.


Create Stream <Create Stream Statement> |
Modify Stream <Modify Stream Statement> |
Modify the stream identified by the specified key. All stream properties are replaced, and data is optionally converted according to the specified default values. Delete Stream <Drop Stream Statement>


<Arithmetic Expression> |
<Expression> BETWEEN <Arithmetic Expression> AND <Arithmetic Expression> |
A BETWEEN B AND C means the same as A >= B AND A <= C, but is a more concise notation, especially when A is a complex expression.
<Select Expression> |
<Expression> OR <Expression> |
<Expression> AND <Expression> |
NOT <Expression> |
<Expression> = <Expression> |
<Expression> != <Expression> |
<Expression> > <Expression> |
<Expression> >= <Expression> |
<Expression> < <Expression> |
<Expression> <= <Expression> |
<Type Id> : <Field Id> |
Selects a field from the current polymorphic stream by explicitly specifying the parent type. Prefixing fields by type is particularly unavoidable when multiple classes have fields with identical names. Unambiguous field references do not require a type prefix. QQL uses the semicolon, rather than the dot, to separate the type identifier from the field identifier, because types are allowed to contain dots in their identifiers.
<Expression> NOT IN ( <Expression List> ) |
<Expression> IN ( <Expression List> ) |
<Expression> LIKE <Expression> |
<Expression> NOT LIKE <Expression> |

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

expression [ NOT ] LIKE pattern, where

expression - any valid expression of character data type;
pattern - specific string of characters to search for in expression, and can include the following valid wildcard characters:
  • % - Any string of zero or more characters.
  • _ - (underscore) Any single character.

LIKE operator is case insensitive.

<Expression> UNION <Expression>


<Arithmetic Expression> + <Arithmetic Expression> |
<Arithmetic Expression> - <Arithmetic Expression> |
<Arithmetic Expression> * <Arithmetic Expression> |
<Arithmetic Expression> / <Arithmetic Expression> |
<New Expression> |
Create an object
<Call Expression> |
Function call
- <Arithmetic Expression> |
<Arithmetic Expression> IS <Type Id> |
Type check, typically used with THIS (*) to recognize the current message type.
<Arithmetic Expression> IS NULL |
Checks that the specified expression evaluates to null. As in SQL, you must use this form, rather than (WRONG) X = NULL.
<Arithmetic Expression> IS NOT NULL |
The inverse of IS NULL
<Arithmetic Expression> AS <id> |
Tags the specified expression with a name. This is particularly useful for specifying field names for the anonymous class created to hold the result of a typical select, e.g.: select a+b as SUM ....
NULL |
<int> |
<float> |
<string> |
<date literal> |
Date literal
<time literal> |
Time literal
<char literal> |
Character literal
<binary literal> |
Binary literal
<Identifier> |
FALSE |
A negative BOOLEAN literal.
TRUE |
A negative BOOLEAN literal.
* |
A * (star) used as an identifier is synonymous with THIS (the current message). In QQL, select * from ... is the same as select this from ....
( <Expression> )








SELECT <Select Mode> <Expression List> [ FROM <Expression> ] [ WHERE <Expression> ] [ GROUP BY <Field List> ]

The SELECT expression creates or transforms a message stream. The input message source generates zero or more messages, possibly of different types. The stream returned by the SELECT expression iterates over the input stream and generates data based on the input information.

There are three ways in which the output message stream may be formed:

  • If the selection list contains a single expression that is either THIS (*), or a supported aggregate of THIS, such as FIRST (*) or LAST (*), then the output message is the same as the input message (defined by the FROM clause).
  • If the selection list contains a single expression of CLASS TYPE, such as the new expression, then the result of computing that expression is returned as the output message.
  • Otherwise, an anonymous (unnamed) message class is implied, consisting of as many non-static fields as there are non-static expressions in the list, and as many static fields as there are static (computed at compile-time) expressions in the list. The field names are derived from expression names.

Omitting the message source (the FROM clause) implies selecting from the special single-message data source. This comes in handy when you simply want to compute a single expression, as in SELECT 2+3.

The WHERE clause, if present, defines the filtering condition, applied to the input messages.

The GROUP BY clause, used when aggregating data, determines how many aggregator instances are created.

Please read the QQL tutorial for an in-depth discussion of how the SELECT expression works.



|
<Select Mode> DISTINCT
Aggregate all output messages and discard duplicates.
|
<Select Mode> RUNNING
RUNNING is useful when aggregate functions are present in the selection list. While the default behavior in such case is to aggregate the data and return its last value, in the RUNNING total mode, all intermediate values are returned.


Will be implemented in near future. Do not use now.


<id> ( <Expression List> )
Applies a data conversion or aggregate function to the specified argument.


<Type Id> ::=
<id> |
<Type Id> . <id>
Type identifiers differ from variables, functions, fields, etc., in that they may contain dots.


<Field Id> ::=
<id>


CREATE <Stream Scope> STREAM <id> [ <string> ] ( <Stream Member List> [ ; ] ) [ <Options> ] [ COMMENT <string> ]
Create a new stream in TimeBase according to the specification. This "query" returns back a stream of messages of the standard type deltix.qsrv.hf.pub.ErrorMessage. Usually one message is returned, either reporting success, or containing error information.


MODIFY STREAM <id> [ <string> ] ( <Stream Member List> [ ; ] ) [ <Options> ] [ COMMENT <string> ]
[ CONFIRM ( NO_CONVERSION | CONVERT_DATA | DROP_ATTRIBUTES | DROP_TYPES | DROP_DATA ) ]
Modify the stream identified by the specified key. All stream properties are replaced, and data is optionally converted according to the specified default values. This "query" returns back a stream of messages of the standard type deltix.qsrv.hf.pub.ErrorMessage. Usually one message is returned, either reporting success, or containing error information.




TRANSIENT |
TRANSIENT streams are in-memory objects, similar to message queues or topics.
DURABLE
DURABLE streams have all loaded data permanently stored on disk.


<Options> ::=
OPTIONS ( <Option List> [ ; ] )
This construct is used for specifying additional options for creating objects, such as the distribution factor for durable streams, buffer properties for transient streams, etc.




<Option> ::=




CLASS <Type Id> [ <string> ] [ UNDER <Type Id> ] ( <Attribute Definition List> ) [ <Instantiable Clause> ] [ COMMENT <string> ]


INSTANTIABLE |
NOT INSTANTIABLE
NOT INSTANTIABLE is the QQL (and Standard SQL) name for what is known in most object-oriented languages as abstract. NOT INSTANTIABLE classes are used as parent classes for other INSTANTIABLE classes in the schema. Concrete messages contained in a stream may only be of INSTANTIABLE class type.








STATIC <id> [ <string> ] <Type Id> = <Expression> [ COMMENT <string> ]

Static attributes are invariable across all messages. The scope of a static attribute, just like that of static class members in languages such as C# or Java, is the entire class, as opposed to individual message (object). Individual messages only contain information about non-static fields.

Static attributes cannot have encoding specification. For example, you define a static INTEGER attribute as STATIC level INTEGER = 28, but there is no place, or need, to specify that it is stored as a 4 byte binary. The value in this case is 28, and that is all TimeBase needs to know.

Static attributes can even be set to NULL, which is especially useful when the are mapped to native object fields on read, and we want TimeBase to set those fields to some invariant value.



<id> [ <string> ] <Data Type> [ RELATIVE TO <Identifier> ] [ DEFAULT <Expression> ] [ COMMENT <string> ]

Non-Static attributes are normal variable fields of a message.

The DEFAULT construct is only used when modifying the stream schema. The schema conversion engine uses the specified value to initialize previously missing or inconvertible field values.



<Limits> ::=
<empty> |
BETWEEN <Expression> AND <Expression>


<empty> |
<id> |
<id> ( <int> )

See TimeBase Data Types for detailed information about standard types and encodings.



<Data Type> ::=
<Type Id> [ NOT NULL ] <Encoding Info> <Limits> |
ARRAY ( <Data Type List> ) [ NOT NULL ] |
OBJECT ( <Object Content DataType List> ) [ NOT NULL ]

See TimeBase Data Types for detailed information about standard types and encodings.







ENUM <Type Id> [ <string> ] ( <Enumeration> ) [ FLAGS ] [ COMMENT <string> ]






<id>


DROP STREAM <Identifier>