In this video,
I’ll give you a brief demo of how to create,
run,
and test a streaming analytics project in SAP HANA studio.
The project I’m going to create will filter data from an input stream,
and then write that data to a HANA database.
In this tutorial,
I will add an input stream to the project,
connect it to a filter,
use an output adapter to write the data to HANA,
compile and execute the project,
and then test the project by manually loading data to the input stream.
For this example,
I’ve created a table in the SYSTEM schema in HANA called 'Table_Test'.
It contains two columns (ID and VALUE),
and two rows.
Now,
it’s time to create the project.
Go to the SAP HANA Streaming Development perspective,
and right-click in the Project Explorer pane.
Go to New,
Other,
SAP HANA streaming analytics,
and New Streaming Project.
Name your project,
then click Finish.
The new project is made up of three files:
ccl,
cclnotation,
and ccr.
The ccl file is the text-version of your project,
whereas the ccl notation file is a graphical representation.
The ccr file is where you configure your project.
For this demo,
I’ll be working in the cclnotation file.
New projects contain an input stream by default,
which you can keep or remove.
For this demo,
you can keep it,
and just give it a new name.
I’ll call mine ‘INPUTSTREAM’.
Next,
I’ll define the schema.
I’m gonna use the same column names as the table in the HANA database,
which are the integers ID and VALUE.
To add a new column,
click the top of the input stream,
and then click the Add Column button.
Next,
I’ll add a filter to the canvas.
Go to the Streams and Windows compartment in the Palette,
and click Filter,
and then the canvas.
Or,
just drag and drop the Filter element to the canvas.
I’ll call this element ‘FilterOutData’.
This filter isn’t valid yet,
as indicated by the red outline.
To make it valid,
attach it to an input stream.
Using the Connector tool,
click on the input stream,
and then on the filter.
Make sure you do it in this order,
and follow the direction of the data flow.
The connector tool won’t work,
if you click the filter first.
The filter is now taking input from the input stream.
Instead of writing all messages to HANA,
filters are a great way to determine what data streaming analytics should process.
In this example,
I’m gonna filter out values from the input stream that are below 20.
To do this,
click the Edit button under Filter,
and press Control and Space to pull up the content list.
Double-click INPUTSTREAM.VALUE,
and append ‘> 20’.
Now,
I’ll configure my project to load data to HANA,
by adding a HANA output adapter,
which you can find in the Output Adapters compartment.
After attaching the adapter to the filter,
you need to specify which table you’ll write data to.
Do this by clicking the menu,
Modify,
then Edit Properties.
Or,
just click the Edit Properties button.
In the Adapter Properties window,
specify the Database Service Name,
Target Database Schema Name,
and Target Database Table Name.
For me,
I’m using the 'hanadb' service,
connecting to the 'SYSTEM' schema,
and writing to the target table, 'Table_Test'.
With those values set,
I’ll compile and execute the project.
To compile,
click the Compile Streaming Project button,
or,
press F7.
This will let you know if you have any errors.
Execute the project by clicking the Run Streaming Project button.
This opens the SAP HANA Streaming Run-Test perspective.
If you’re connected to the streaming server and the project is on,
it shows you the running project.
The project is successful because there is no error dialog,
and I can see the project below the server folder.
It contains the filter,
output adapter,
and input stream.
Finally,
I’ll test the project by adding data to it.
There are many ways to load data to the input stream,
but I’ll use the manual method.
But first,
I’ll open the filter and input stream,
so I can see the data as I publish it.
To manually load data,
go to the Run-Test perspective,
and under the Manual tab,
select the appropriate stream.
An input stream normally processes data from an input adapter or publisher.
This method, however,
allows you to enter data as if a message were coming into the input stream.
I’ll add two rows.
The first will have an ID of 3,
and a value of 9.
To execute the data,
click Publish.
The second row will have an ID of 4,
and a value of 21.
The new data shows in the input stream,
but,
only the second row I added shows in the filter.
This is because it contains a value greater than 20.
Since I used a value below 20 for the first row,
the data was filtered out.
As a result,
only the second row I added,
will load to the table in the HANA database.
You can check this by going to the Admin console,
right-clicking on the table,
and selecting Open Content.
See?
Only the second row I added, shows up.
Stay tuned,
for a second video on how to monitor this project in cockpit.
For more information,
take a look at the streaming documentation,
and check out the full library of streaming videos on the HANA Academy.
Thanks for watching!