CREATE INPUT STREAM Statement

Syntax

CREATE [PUBLIC] INPUT STREAM stream_identifier 
  named_schema_identifier|anonymous_schema [ WITH PARAMETERS  (
    parameter_name = "parameter_value" [, ...] 
)];

Substitutable Fields

stream_identifier

A unique identifier (name) for the input stream.

named_schema_identifier

The identifier of a previously-defined named schema. Imports all of the named schema's fields. No parentheses are required, and no other fields are permitted. Named schemas must be defined in dependency order. If a schema is used before it is defined, an error results.

anonymous_schema

A schema definition, delimited by parentheses, in the following format:

(field_definition [, ...])
field_definition

A field definition takes the form:

field_identifier field_type

field_identifier

A unique name for a field in the schema associated with the stream. For table indexes, if the field references a named schema, the entire schema is used as the key.

field_type

One of the supported StreamBase data types.

parameter

A parameter takes the form:

parameter_name parameter_value

parameter_name

The name of a StreamBase parameter appropriate to the statement

parameter_value

A quoted value for the parameter, which if a string must include escaped quotes

Examples

The following statements create a named schema and reference it in an input stream:

CREATE SCHEMA SymbolSchema (ID int, Symbol string, Price double);
CREATE INPUT STREAM Input1 SymbolSchema;

The input stream statement above is equivalent to the following, using an anonymous schema:

CREATE INPUT STREAM Input1 (ID int, Symbol string, Price double);

The next two input statements use anonymous schemas:

CREATE INPUT STREAM Input2
  (ID int, Symbol string, Price double);

CREATE INPUT STREAM Input3
  (ss SymbolSchema, Quantity int);

The second anonymous schema combines a reference to the named schema shown earlier with another field. It is equivalent to:

ss (ID int, Symbol string, Price double), Quantity int

Discussion

The CREATE INPUT STREAM statement defines an Input Stream. The types and order of fields contained in the incoming tuples must either be defined in an anonymous schema, or referenced from a previously defined named schema.

To use a named schema, simply provide its name. To use an anonymous schema, declare a comma-separated list of fields, specifying the identifier and data type of each, and enclose the schema in parentheses.

You must define a schema. For example, the statement CREATE INPUT STREAM () will result in a runtime error.

Use the optional PUBLIC keyword to designate that this stream is to be available for enqueuing, no matter how deeply the module that contains this stream is nested in a complex application.

To create streams with schemas that cannot be overridden, precede CREATE INPUT STREAM with a USING HYGIENIC statement. For example:

USING HYGIENIC;
CREATE INPUT STREAM TradesIn (
symbol string, – Stock symbol
quantity int – Number of shares
);
...

When this module is called, the schema of tuples it receives must exactly match the schema declared above. If you convert an EventFlow module to StreamSQL, you can achieve this by first clearing the References to this module override Input Schemas check box on the Annotations tab. For more information, see Hygienic Modules.