A couple of days ago, I started to think about SAP HANA and R on Amazon Web Services…as far as I know, graphics can’t get generated using this kind of integration because the graphic will get generated on the server and could not make the trip back into HANA Studio…so I kept thinking as said to myself…”Wouldn’t it be a good idea to use a Linux command to send my email the graphics generated in the R server?”…I had a deal for sure…
I spend a couple of days trying to install X11 on my SUSE box…until I discovered…that it’s a headless server and doesn’t provide any support for X11…that really bring me down as I tried to hard…anyway…as nothing can stop my ideas from becoming some real…I thought of using PDF generation as it doesn’t need X11 at all…but…today…after doing some more research…I discovered that the Cairo library supports image creation without the need of X11…
If you haven’t installed SAP HANA and R on Amazon Web Services, read this… When SAP HANA met R – First kiss.
Let’s take a look at what we need to do:
|zypper install cairo-devel|
|Install Cairo library on R|
|Start the Rserve server|
|R CMD Rserve –RS-port 6311 –no-save –RS-encoding “utf8″|
Using the same user you used for starting the Rserver Server, create a folder and change it’s permissions…
|>chmod 777 Blag|
|drop procedure GetTicketsByYearMonth;
drop procedure Generate_Graphic;
drop procedure Get_Tickets;
CREATE PROCEDURE GetTicketsByYearMonth(IN var_year NVARCHAR(4),IN var_month NVARCHAR(2))
CREATE PROCEDURE Generate_Graphic(IN tickets_year TICKETS_BY_YEAR_MONTH, OUT result TICKETS_BY_YEAR_MONTH)
CREATE PROCEDURE Get_Tickets()
When we execute this, a couple of things are going to happen…
- We’re going to get the amount of tickets per airline and per year and month. We’re going to save this info in a table.
- We’re going to read this information, create a graphic and save it as an .png
- We’re going to send this graphic to ourselves by email.
After execution, we’re going to see a nice email…
Cool, huh? Now, we can create graphics on SAP HANA and R on Amazon Web Services -;)