CREATE TABLE (Stream Analytics)

 

Updated: April 22, 2016

Applies To: Azure

The Create table statement is used to define the schema of the payload of the events coming into Azure Stream Analytics. This allows the user to explicitly define the data types of each named column for the payload of incoming events.

It’s important to understand that CREATE TABLE does not actually create any table but only defines the data type for each column in the payload of the Input alias that has been created in the “Add Input” section of the portal. In the absence of such a declaration, the compiler will infer the data type of the columns. If the data is in CSV or JSON format, then all inferred types will be nvarchar(max). To perform non-text operations or transformations on the data, the data types either need to be defined using CREATE TABLE or established using the CAST function within the query.

Syntax

CREATE TABLE   
    table_name   
    ( column_name <data_type> [ ,...n ] );  
  

  • table_name

    The name of the input stream where the data is coming from. This name needs to match the input alias created in the “Add Input” section of the Azure Stream Analytics portal.

  • column_name

    The name of the column in the payload of the incoming event. If there are no column names in the payload, then default names of column1, column2, … are generated by the system and should be used here in the CREATE TABLE statement.

  • data_type

    The data types which are supported by Azure Stream Analytics. See Data Types (Azure Stream Analytics).

  
CREATE TABLE TollTagEntry (  
   TollId nvarchar(max),  
   EntryTime datetime,  
   LicensePlate nvarchar(max),  
   State nvarchar(max),  
   Make nvarchar(max),  
   Model nvarchar(max),  
   VehicleType nvarchar(max),  
   VehicleWeight nvarchar(max),  
   Toll float,  
   Tag nvarchar(max)  
);  
  

Show: