Query Language
Query Language
caution
This document is for TimeBase Community Edition and TimeBase Enterprise Edition 5.5
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]
SELECT [DISTINCT|RUNNING]
simple_expr_list|record_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, andWHEN
sets a condition.
info
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.
CREATE TRANSIENT|DURABLE STREAM stream_name [title]
(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']
[CONFIRM NO_CONVERSION|CONVERT_DATA|DROP_ATTRIBUTES|DROP_TYPES|DROP_DATA]
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 [, ...])
[AUXILIARY|NOT AUXILIARY]
[INSTANTIABLE|NOT INSTANTIABLE]
[COMMENT 'comment text']
ENUM enum_name [title]
(identifier [= expr] [, ...])
[FLAGS]
[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 containAUXILIARY
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 withSTATIC
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 akey:value
pair.
info
Refer to DDL Tutorials to learn more about using DDL.