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
FROMone or several streams and filter them using WHERE clause. - Use WITH keyword to declare aliases, variables, expressions.
- You can query data in
LIVEmode, 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
TYPEsets a new type, andWHENsets 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
UNDERto indicate a parent class if applicable. - Classes may include static and/or non-static attributes. You can list them separated by a comma.
AUXILIARYclasses cannot be written to a stream, but stream objects may containAUXILIARYclasses.NOT AUXILIARYclasses can be written to a stream.NOT INSTANTIABLEare abstract classes.- Use
FLAGSto store enum values encoded as bitmask. - Use
COMMENTto 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
exprvalues withSTATICattributes. - All attributes may acquire null values unless they are
NOT NULL. - Attributes may have different data types and encoding.
- Use
BETWEEN/ENDto assign minimal and maximal values to numeric attributes. - Non-static attributes may acquire
DEFAULTvalues. - Use
RELATIVE TOto indicate that a non-static attribute's decoding depends on another field/property value. - With
TAGSyou can store a specific field-related metadata as akey:valuepair.
info
Refer to DDL Tutorials to learn more about using DDL.