Skip to content
eliquious edited this page Jul 13, 2015 · 1 revision

Type Definitions

Each log has a defined type much like a table schema in a traditional RDBMS. There are, however, several key differences. SKL supports nested types and native arrays for both primitives and other complex types. The type defs are designed to grow along with the data and can be updated as your data changes.

Creating Types

Types can be created with the CREATE TYPE notation shown below.


// This creates new type called Latitude with 3 64-bit floats fields: latitude, longitude and altitude.
CREATE TYPE Location WITH latitude float64, longitude float64, altitude float64;

// This creates a new type called User with a uuid and a username, along with an optional array of strings for email addresses.
CREATE TYPE User WITH uuid string, username string, OPTIONAL emails []string;

Field Modifiers

Mandatory fields

Fields which are mandatory are modified with the REQUIRED keyword. If a field is not modified with either REQUIRED or OPTIONAL, the field is also mandatory.

Optional fields

Likewise, if a field is not required it is modified with the OPTIONAL keyword.

Update Type (add fields)

Types can be updated by adding additional fields but fields cannot be removed once added. Fields can also be annotated with REQUIRED and OPTIONAL denoting whether a field is mandatory.


// This adds an optional 8-bit age field.
UPDATE TYPE Location WITH OPTIONAL FIELD age uint8;

// This updates the User type with a required location type and an optional array of friends.
UPDATE TYPE User WITH REQUIRED location Location, OPTIONAL friends []User;

Describe Type Definition


// This returns a schema-like document which outlines the current structure of a type.
DESCRIBE TYPE Location;