cancel
Showing results for 
Search instead for 
Did you mean: 

Link to .R Script File in Hana

0 Kudos
310

We integrated R successfully into Hana, with R Serve on a Linux machine.
But we don't want to put the whole R Script into the SQL script in Hana, we just want to link to an .R File on the R-Server where the R Script is written down.

We tried the normal way in RStudio with source("FILE PATH") and we used the file path on the Linux machine. Does this code even work or does the file path be a different one?

Accepted Solutions (1)

Accepted Solutions (1)

We could manage it to get run an .R File in the SQL Script.
The code ist quiet easy.

source(file="FILE PATH")

The file path needs to be absolut. It's also possible to call a second .R File from within the first (directly called file).

So in our Testscript we called (in SQL Hana) the R Code and created an Hana Table. The Hana table was filled with data, we read out of an csv file in the .R Script.

lbreddemann
Active Contributor
0 Kudos

Is your RServe running on the same system as HANA?

0 Kudos

lbreddemann No, they are running on two different servers.

lbreddemann
Active Contributor
0 Kudos

Ok, so the file path was absolut and reachable for the RServe user, correct?

lbreddemann Yes, correct. We have RServe on a Linux Machine. The Script was written in RStudio Web Edition, on the RServer.

Answers (1)

Answers (1)

lbreddemann
Active Contributor

There is no way to link an .R file in the way you describe. The R code has to be part of the SAP HANA calculation view.

As HANA does not process the code itself, the R integration works by using a channel from the HANA server processes to the RServe process to hand over the R code and the data.

You may try and source other files that are available to the R instance that Rserve creates - similar to the R libraries. This of course requires that the HANA calculation view provides and receives all input/output data.