3.1 Data Types
EventQL supports a number of SQL data types in several categories: numeric types, date and time types and string types. This page provides an overview of these data types and a summary of the data type storage requirements.
Data Types
| Type | Min Value | Max Value | Size (Bits) |
|---|---|---|---|
| STRING | — | — | 8-32 + $len * 8 |
| DOUBLE | -1.7976931348623157E+308 | 1.7976931348623157E+308 | 64 |
| UINT32 | 0 | 4294967295 | 8-32 |
| UINT64 | 0 | 18446744073709551615 | 8-64 |
| BOOLEAN | 0 | 1 | 1 |
| DATETIME | 0 | 18446744073709551615 | 8-64 |
| RECORD | — | — | 0 |
Repeated Fields
EventQL schemas allow for a type to be specified as repeated. A repeated field
can be repeated any number of times (including zero) in a well-formed row.
The order of the repeated values will be preserved.
Let's look at a simple example:
CREATE TABLE ev.temperature_measurements (
collected_at DATETIME,
sensor_id STRING,
measured_values REPEATED STRING,
PRIMARY KEY(collected_at, sensor_id)
);
And an example JSON message that is valid for the above schema:
{
"collected_at": "2016-07-05 13:34:51",
"sensor_id": "sensor1",
"measured_values": [ "A", "B", "C"]
}
The RECORD Type
The record type allows you to define nesting within a column. Its most useful in combination with repeated fields as this allows you to build schemas that can properly represent arbitrary JSON objects.
We can modify our example above to include a location with each measure value:
CREATE TABLE ev.temperature_measurements (
collected_at DATETIME,
sensor_id STRING,
measurements REPEATED RECORD (
thing_id STRING,
temperature DOUBLE
),
PRIMARY KEY(collected_at, sensor_id)
);
This JSON message can now be stored:
{
"collected_at": "2016-07-05 13:34:51",
"sensor_id": "sensor1",
"measured_values": [
{ "thing_id": "thing1", temperature: 22.3 },
{ "thing_id": "thing2", temperature: 21.8 },
{ "thing_id": "thing3", temperature: 24.5 },
]
}