Pump

<< Click to Display Table of Contents >>

Navigation:  Understanding Streaming SQL Concepts > SQLstream Overview >

Pump

Previous pageReturn to chapter overviewNext page

Moving data from place to place in s-Server involves pumps. A pump wraps around a standard SQL INSERT INTO or SELECT FROM query, but gives this query an execution context.

Because of the nature of streaming data--it has to be moving in order for you to work with it--pumps are a crucial part of programming with s-Server. They let you perform different analytics on the same data set, "enrich" data using historical data. Above all, they let you query data at multiple stages in your application.

Eventually, you will develop pipelines with pumps, whereby a series of pumps move data from stream to stream.

sbur_pump_diagram

The example below first creates and sets the schema "Test," then creates two streams, "OrderDataWithCreateTime" and "OrderData, then creates a pump that selects from the first stream and inserts into the second stream.

CREATE OR REPLACE SCHEMA "Test";

SET SCHEMA '"Test"';

 

CREATE OR REPLACE STREAM "OrderDataWithCreateTime" (

"key_order" VARCHAR(20),

"key_user" VARCHAR(20),

"key_billing_country" VARCHAR(20),

"key_product" VARCHAR(20),

"quantity" VARCHAR(20),

"eur" VARCHAR(20),

"usd" VARCHAR(20))

DESCRIPTION 'Creates origin stream for pump';

 

CREATE OR REPLACE STREAM "OrderData" (

"key_order" VARCHAR(20),

"key_user" VARCHAR(20),

"country" VARCHAR(20),

"key_product" VARCHAR(20),

"quantity" VARCHAR(20),

"eur" INTEGER,

"usd" INTEGER)

DESCRIPTION 'Creates destination stream for pump';

 

CREATE OR REPLACE PUMP "200-ConditionedOrdersPump" STOPPED AS

INSERT INTO "OrderData" (

"key_order", "key_user", "country",

"key_product", "quantity", "eur", "usd")

SELECT STREAM

"key_order", "key_user", "key_billing_country",

"key_product", "quantity", "eur", "usd"

FROM "OrderDataWithCreateTime";