Schemas

A schema defines the structure of data rows in a stream or window.

Every row in a stream or window must have the same structure, or schema, which includes the column names, the column datatypes, and the order in which the columns appear. Multiple streams or windows may use the same schema, but a stream or window can only have one schema.

There are two ways to create a schema: you can create a named schema using the CREATE SCHEMA statement or you can create an inline schema within a stream or window definition. Named schemas are useful when the same schema will be used in multiple places, since any number of streams and windows can reference a single named schema.

Simple Schema CCL Example

This is an example of a CREATE SCHEMA statement used to create a named schema. TradeSchema represents the name of the schema.

CREATE SCHEMA TradeSchema (
		Ts BIGDATETIME, 
		Symbol STRING, 
		Price MONEY(4), 
		Volume INTEGER
);

This example uses a CREATE SCHEMA statement to make an inline schema:

CREATE STREAM trades SCHEMA (
		Ts bigdatetime, 
		Symbol STRING, 
		Price MONEY(4), 
		Volume INTEGER
);