Skip to main content

Query Language

Query Language


This document is for TimeBase Community Edition and TimeBase Enterprise Edition 5.5

For older versions refer to QQL 5.4 .

Refer to QQL 5.5 Breaking Changes for your information.

TimeBase QuantQuery Language (QQL) is a query language designed to extract, filter, aggregate and transform data in TimeBase streams.

While QQL is very similar to SQL, there are very significant differences. QQL is designed to query polymorphic time-series data, while SQL is designed primarily for querying monomorphic (fixed-structure) data, without any time-series properties.

[WITH expr_list]
[FROM stream_name|REVERSE(stream_name)|LIVE(stream_name)]
[[LEFT] ARRAY JOIN expr_list]
[[TRIGGER|RESET] OVER [EVERY] [count_expr|time_expr]]
[WHERE expr]
[GROUP BY expr_list]
[LIMIT limit [OFFSET offset]]|[LIMIT offset, limit]
[UNION ...]
expr_list [TYPE type_name]
[RECORD expr_list TYPE type_name WHEN expr, RECORD expr_list TYPE type_name WHEN expr, ...]
  • SELECT allows querying all data or DISTINCT entries FROM one or several streams and filter them using WHERE clause.
  • Use WITH keyword to declare aliases, variables, expressions.
  • You can query data in LIVE mode, REVERSE order or get data RUNNING for every message received.
  • With the TYPE keyword you can set the query output type or map it to the specific class type.
  • ARRAY JOIN`s allow joining nested arrays in a single message.
  • With OVER you can compute query output for a specific window or count.
  • Use GROUP BY to output just the data aggregated by a specific value.
  • With LIMIT you can define the output volume. In combination with OFFSET you can also set the starting record number.
  • UNION allows combining queries even with different types.
  • Use RECORD ... TYPE ... WHEN construction to return a polymorphic set, where TYPE sets a new type, and WHEN sets a condition.

Refer to QQL Tutorials to learn more about using QQL.

Data Definition Language

TimeBase Data Definition Language (DDL) you can CREATE, MODIFY, and DROP streams.

(class_expr|enum_expr [; ...])
[OPTIONS (identifier [= expr] [; ...])]
[COMMENT 'comment text']

MODIFY STREAM stream_name [title]
(class_expr|enum_expr [; ...])
[OPTIONS (identifier [= expr][; ...])]
[COMMENT 'comment text']

DROP STREAM stream_name
  • You can create DURABLE and TRANSIENT types of streams.
  • Specify separated by a semicolon all classes and enumerations included in your stream.
  • Add stream definition attributes in OPTIONS.

where classes and enumerations are described as follows:

CLASS type_name [title] [UNDER type_name]
(static_attribute|attribute [, ...])
[COMMENT 'comment text']
ENUM enum_name [title]
(identifier [= expr] [, ...])
[COMMENT 'comment text']
  • Use UNDER to indicate a parent class if applicable.
  • Classes may include static and/or non-static attributes. You can list them separated by a comma.
  • AUXILIARY classes cannot be written to a stream, but stream objects may contain AUXILIARY classes. NOT AUXILIARY classes can be written to a stream.
  • NOT INSTANTIABLE are abstract classes.
  • Use FLAGS to store enum values encoded as bitmask.
  • Use COMMENT to add your comment to the query.

and where static and non-statics attributes are determined as follows:

STATIC identifier [title] type [NOT NULL] [encoding] [BETWEEN min_expr AND max_expr] = expr
[TAGS (identifier:expr [, ...])]
[COMMENT 'comment text']
identifier [title] type [NOT NULL] [encoding] [BETWEEN min_expr AND max_expr] [RELATIVE TO identifier] [DEFAULT expr]
[TAGS (identifier:expr [, ...])]
[COMMENT 'comment text']
  • Supply a specific expr values with STATIC attributes.
  • All attributes may acquire null values unless they are NOT NULL.
  • Attributes may have different data types and encoding.
  • Use BETWEEN/END to assign minimal and maximal values to numeric attributes.
  • Non-static attributes may acquire DEFAULT values.
  • Use RELATIVE TO to indicate that a non-static attribute's decoding depends on another field/property value.
  • With TAGS you can store a specific field-related metadata as a key:value pair.

Refer to DDL Tutorials to learn more about using DDL.