A stream is a logical series of events ordered in time. Its schema is defined via the stream definition. A stream definition contains the stream name and a set of attributes with specific types and uniquely identifiable names within the stream. All events associated to the stream will have the same schema (i.e., have the same attributes in the same order).
The stream processor groups common types of events together with a schema. This helps in various ways such as, processing all events together in queries and performing data format transformations together when they are consumed and published via sources and sinks.
The syntax for defining a new stream is:
CREATE STREAM <stream_name> (<attribute_name> <attribute_type>,
<attribute_name> <attribute_type>, ... );
The following parameters are used to configure a stream definition.
|The name of the stream created. (We recommend defining stream names in |
|Uniquely identifiable name of the stream attribute. (It is recommended to define attribute names in |
|The type of each attribute defined in the schema. This can be |
To use and refer stream and attribute names that do not follow
[a-zA-Z_][a-zA-Z_0-9]* format, enclose them in
`. For example:
To make the stream process events with multi-threading and asynchronously, add
Async to the
WITH() property. For example:
This example creates a stream called
TempStream with the following attributes:
CREATE STREAM TempStream (deviceID long, roomNo int, temp double);
Using Streams as Source and Sink
You can use streams as sinks and sources for stream workers.