CREATE STREAM - Amazon Kinesis Data Analytics SQL Reference

CREATE STREAM

The CREATE STREAM statement creates a (local) stream. The name of the stream must be distinct from the name of any other stream in the same schema. It is good practice to include a description of the stream.

Like tables, streams have columns, and you specify the data types for these in the CREATE STREAM statement. These should map to the data source for which you are creating the stream. For column_name, any valid non-reserved SQL name is usable. Column values cannot be null.

  • Specifying OR REPLACE re-creates the stream if it already exists, enabling a definition change for an existing object, implicitly dropping it without first needing to use a DRP command. Using CREATE OR REPLACE on a stream that already has data in flight kills the stream and loses all history.

  • RENAME can be specified only if OR REPLACE has been specified.

  • For the complete list of types and values in type_specification, such as TIMESTAMP, INTEGER, or varchar(2), see the topic Amazon Kinesis Data Analytics Data Types in the Amazon Kinesis Data Analytics SQL Reference Guide.

  • For option_value, any string can be used.

Simple stream for unparsed log data

CREATE OR REPLACE STREAM logStream (    source  VARCHAR(20),    message VARCHAR(3072)) DESCRIPTION 'Head of webwatcher stream processing';

Stream capturing sensor data from Intelligent Travel System pipeline

CREATE OR REPLACE STREAM "LaneData" (    -- ROWTIME is time at which sensor data collected    LDS_ID  INTEGER,        -- loop-detector ID    LNAME   VARCHAR(12),    LNUM    VARCHAR(4),    OCC     SMALLINT,    VOL     SMALLINT,    SPEED   DECIMAL(4,2) ) DESCRIPTION 'Conditioned LaneData for analysis queries';

Stream capturing order data from e-commerce pipeline

CREATE OR REPLACE STREAM "OrderData" (    "key_order"    BIGINT NOT NULL,    "key_user"     BIGINT,    "country"      SMALLINT,    "key_product"  INTEGER,    "quantity"     SMALLINT,    "eur"          DECIMAL(19,5),    "usd"          DECIMAL(19,5) ) DESCRIPTION 'conditioned order data, ready for analysis';