Quantcast
Channel: SCN : All Content - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6745

Problem Processing R Script in HANA Stored Procedure

$
0
0

Hello Community,

I'm having a problem running R script in a stored procedure. The procedure is created successfully, but the script doesn't seem to be parsed properly.  I tested each of the lines in the R script directly in R and they work as intended but when I call the script I get various errors back like END not found, object (variable name) not found.  See below for details.

 

I included log details from similar errors that occurred when running other simple R commands in the stored procedure.

 

Thanks in advance for the help, I'm stumped.

 

System Details

  • I'm running SAP HANA on an AWS instance and Rserve on a separate AWS instance.
  • I'm using R version 2.15.3 and Rserve version 0.6-8.1.x.
  • cer_rserve_maxendsize = 0 and cer_timeout = 3600

 

Procedure Code

 

CREATE PROCEDURE "MYSCHEMENAME"."MYPROCEDURENAME" (OUT results "SCHEMANAME"."RTEST")

LANGUAGE RLANG AS

 

/********* Begin Procedure Script ************/

BEGIN

 

v <- c(2,3,5,7,2,3)

w <- c(2,3,5,7,2,3)

results <- as.data.frame(cbind(w, v))

 

END;

 

/********* End Procedure Script ************/

 

Procedure Call

 

CALL "MYSCHEMENAME"."MYPROCEDURENAME" ("SCHEMANAME"."RTEST") WITH OVERVIEW;

 

Trace Details from various attempts to run the script (indexserver_alert_imdbhdb.trc)

 

pop = executorPy.ceRPop() # pop1

pop.setNodeName('$$RESULTS$$_SYS_SS_CE_182588_TMP_CALL')

pop.setUseInternalTable()

pop.addViewAttribute('IP', datatype=73, intDigits=5, sqlType=3, sqlLength=5)

pop.addViewAttribute('IPNUMBER', datatype=73, intDigits=5, sqlType=3, sqlLength=5)

pop.setUserSchema('SYSTEM')

pop.addPlanDebugOpDataInfo(originalNodeName = '$$RESULTS$$', scenarioName = 'DATA_OVERLAY:_SYS_SS_CE_182588_TMP')

pop.setRScript('c(2,3,5,7,2,3)\nw <- c(2,3,5,7,2,3)\nresults <- as.data.frame(cbind(w, v))\n\n\nEND;')

pop.setROperationExecutionType(3)

pop.setRNodeEngineType(0)

pop.setRTimeout(3600)

pop.setRPid(0)

pop.setMaxSendSize(0)

pop.addRServerAddress(172.31.6.167:30020)

pop.setOrgNodeName('$$RESULTS$$')

[4943]{300040}[-151040] 2013-05-25 22:53:15.629844 e cePlanExec   cePlanExecutor.cpp(06157) : Error during Plan execution of model DATA_OVERLAY:_SYS_SS_CE_182588_INS (-1), reason: Execution of R script failed.;Error in cbind(w, v) : object 'v' not found

stack trace:

2: cbind(w, v)

1: as.data.frame(cbind(w, v))

 

 

pop = executorPy.ceRPop() # pop1

pop.setNodeName('$$RESULTS$$_SYS_SS_CE_180686_TMP_CALL')

pop.setUseInternalTable()

pop.addViewAttribute('IP', datatype=73, intDigits=5, sqlType=3, sqlLength=5)

pop.addViewAttribute('IPNUMBER', datatype=73, intDigits=5, sqlType=3, sqlLength=5)

pop.setUserSchema('SYSTEM')

pop.addPlanDebugOpDataInfo(originalNodeName = '$$RESULTS$$', scenarioName = 'DATA_OVERLAY:_SYS_SS_CE_180686_TMP')

pop.setRScript('s <- as.data.frame(cbind(c(2,3,5.5,7.1,2.1,3), c(2,3,5.5,7.1,2.1,3)))\nEND;')

pop.setROperationExecutionType(3)

pop.setRNodeEngineType(0)

pop.setRTimeout(3600)

pop.setRPid(0)

pop.setMaxSendSize(0)

pop.addRServerAddress(172.31.6.167:30020)

pop.setOrgNodeName('$$RESULTS$$')

[5019]{300056}[-146694] 2013-05-25 16:34:29.636428 e cePlanExec   cePlanExecutor.cpp(06157) : Error during Plan execution of model DATA_OVERLAY:_SYS_SS_CE_180686_INS (-1), reason: Execution of R script failed.;Error: object 'END' not found

stack trace:

 

[5019]{300056}[-146705] 2013-05-25 16:36:06.584406 e Executor     PlanExecutor.cpp(00219) : pop=pop1, class="ceRPop", duration=16:36:06.550  +0.169, MemAllocBytes=0, MemDeallocBytes=0, CacheLikeMemAllocBytes=0, CacheLikeMemDeallocBytes=0, rc=34080, msg=R script syntax error;Error in  <text>:1:71: unexpected symbol

1: s <- as.data.frame(cbind(c(2,3,5.5,7.1,2.1,3), c(2,3,5.5,7.1,2.1,3))) END

                                                                         ^

 

[5240]{300056}[-146733] 2013-05-25 16:40:47.562231 e RClient      RserveConnection.cpp(00478) : RserveConnection::parseRScript:parseRscript errror

[5240]{300056}[-146733] 2013-05-25 16:40:47.602424 e RClient      RserveConnection.cpp(00055) : Error: error message from Rserve is Error in  <text>:1:4: unexpected ','

1: 5.5,

      ^


Viewing all articles
Browse latest Browse all 6745

Trending Articles