You will learn
- How to create a new streaming project
- Define an input stream to receive incoming events, including the field structure (schema) for the incoming events
- Add a filter to apply to the event stream
By Jeff Wootton
Create a SAP HANA Smart Data Streaming (SDS) project using the streaming plug-in for Eclipse.
In this tutorial series we will be building a project using a simple Internet of Things (IoT) scenario. Our project will be designed to monitor a set of freezer units that are equipped with sensors to report temperature, power on/off events, and door open/close events. We will apply various operators to analyze and transform this data, generate alerts, and capture information in the HANA database.
Click the File menu. Then click the New > Project….
Expand SAP HANA smart data streaming and select New Streaming Project, then click Next.
freezer_monitor in the Name box (be sure to only use lower case) and accept the default Directory location.
All events enter a streaming project via an input stream or input window. When you created the project, it created an input stream called “NEWSTREAM” by default. We will use that stream and just rename it. Alternatively you could add another input stream (or window) by dragging it from the palette and dropping it into the project diagram.
Click the icon to the left of the name NEWSTREAM and change the name of this stream to MACHINEDATA, then press Enter key.
Note that stream names are case sensitive
Streams and windows all have a fixed set of typed columns (aka schema). Events arriving on a particular input stream must contain a set of fields that is compatible (number and type of fields) with the input stream. Events with different field sets will typically be processed by different input streams.
Click on the + to the left of Schema to expand it.
Select the MACHINEDATA shape so that the toolbar appears. Click on the Add Column tool.
Click on Add Column three more times, so there are a total of 5 columns.
Double click on the name
Column1 and change the name of this column to MACHINEID.
Double click on (INTEGER) to the right of MACHINEID to change the datatype for this column to string. (after double clicking, click the drop down arrow, and select string)
Change the rest of the column names and data types as follows:
Note that column names are case sensitive
Your stream should look like this:
Click here - to collapse the shape.
Note: You can just drag the shape to a new position to organize our diagram.
Drag and drop the Filter item in the Streams and Windows drawer of the Palette into the canvas.
Rename the stream,
ACTIVITY_HIST by clicking on the filter icon.
Select Connector from the Palette.
Click on the
MACHINEDATA shape and then on the
ACTIVITY_HIST shape in the visual editor to connect them, directing the data flow from the input stream to the filter.
Double-click on the 1 under
ACTIVITY_HIST > Filter to edit the filter expression.
MACHINEDATA.EVENT_NAME='DOOR' in the text box to define the filter expression.
Note that you can use Ctrl+Space for content assist. Confirm your entry by pressing the Enter key.
Click on the All Iconic button (icon shown below) to collapse all the items.