Tutorial 2B: Coding Streaming SQL in SQLstream sqlLine
SQLstream s-Server lets you query streaming data by using SQL (Structured Query Language), the same language that developers have been using to query traditional databases for decades.
This tutorial describes the steps for setting up a log file source and analyzing it, by coding blocks of SQL. You can execute SQL directly through a command-line program called sqlLine. sqlLine executes SQL code against SQLstream s-Server. A version of sqlLine ships with s-Server, and comes pre-configured to connect with s-Server.
The tutorial includes the following steps:
Overview of Streaming SQL
The type of SQL that runs in s-Server is called streaming SQL. This SQL is based on the SQL:2008 ANSI standard, with some modifications. s-Server' streaming SQL is described in the Streaming SQL Reference Guide.
SQLstream’s main enhancement to the SQL standard concerns the STREAM object. The process of creating streams in streaming SQL is similar to the process of creating tables in a database system like PostgreSQL or Oracle. Like database tables, streams have columns with column types. Once you create a stream, you can query it with a SELECT statement, or insert into it using an INSERT statement.
A block of SQL that creates a stream looks something like the following.
CREATE OR REPLACE SCHEMA "buses_schema";
SET SCHEMA '"buses_schema"';
CREATE OR REPLACE FOREIGN STREAM "buses_stream"
( "id" DOUBLE,
Note that you declare types for each column. Data types determine what kind of data a column can contain. For example, a VARCHAR() column contains a character string of variable length.