Create a Streaming Project with SAP HANA Streaming Analytics
- How to create a new streaming project
- How to define an input stream to receive incoming events, including the field structure (schema) for the incoming events
- How to add a filter to apply to the event stream
In this tutorial series you will build a project using a simple Internet of Things (IoT) scenario. The 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. You will apply various operators to analyze and transform this data, generate alerts, and capture information in the HANA database.
- Step 1
Go to File > New > Project….
Expand SAP HANA streaming analytics and select New Streaming Project, then Next.
freezer_monitorin the Name field (be sure to only use lowercase) and accept the default Directory location.
What perspective opens after you create the project?
- Step 2
All events enter a streaming project via an input stream or input window. When you create the project, it creates a default input stream called “NEWSTREAM”.
Use this stream and just rename it. Alternatively, add another input stream (or window) by dragging it from the Palette and dropping it onto the project diagram.
Click the icon to the left of the stream’s name and change it to MACHINEDATA, then press Enter.
Note that stream names are case-sensitive
- Step 3
Streams and windows all have a fixed set of typed columns (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 are typically processed by different input streams.
Click on the + to the left of Schema to expand it.
Select the MACHINEDATA element so that the toolbar appears. Choose the Add Column option.
Click Add Column three more times, so there are a total of 5 columns.
Double-click on the column name
Column1and change it to MACHINEID.
Double-click on (INTEGER) to the right of MACHINEID to change the data type for this column to string (after double-clicking, select the dropdown arrow, and choose string).
Change the rest of the column names and data types as follows:
Note that column names are case-sensitive
Column Name Type
Your stream should look like this:
Click the - button to collapse the element.
Note that you can just drag the element to a new position to organize your diagram.
- Step 4
Drag and drop the Filter element from the Streams and Windows drawer of the Palette onto the canvas.
Rename the stream,
ACTIVITY_HISTby clicking on the filter icon.
- Step 5
Select Connector from the Palette.
Click on the
MACHINEDATAelement and then on the
ACTIVITY_HISTelement in the visual editor to connect them. This directs the data flow from the input stream to the filter.
- Step 6
Double-click on the 1 under
ACTIVITY_HIST> Filter to edit the filter expression.
MACHINEDATA.EVENT_NAME='DOOR'in the text field to define the filter expression.
Note that you can use Ctrl+Space for content assist. Confirm your entry by pressing Enter.
Select the All Iconic option (icon shown below) to collapse all the items.