Calling R function within SQL - HANA database

喜夏-厌秋 提交于 2019-12-25 06:07:16

问题


When I call Linear Regression function of R on the data set I get an error message stating

Could not execute 'CALL ANAGAPPAN.USE_LM("POWER_CONSUMPTION","POWER_CONSUMPTION_OUT") WITH OVERVIEW' in 280 ms 668 µs . SAP DBTech JDBC: [2048]: column store error: search table error: [34086] Convert data error: Convert Data from R to NewDB failed.;Column 'POWER_APP' not computed from R.

Code is

SELECT POWER_APP,POWER_DB,CPUTI,DBTI,DBSU,KBYTES_TRANSFERRED FROM "POWER_CONSUMPTION";
CREATE COLUMN TABLE "POWER_CONSUMPTION_OUT" LIKE "POWER_CONSUMPTION" WITH DATA;

DROP PROCEDURE USE_LM;
CREATE PROCEDURE USE_LM(IN train "POWER_CONSUMPTION",OUT result "POWER_CONSUMPTION_OUT")
LANGUAGE RLANG AS
BEGIN
model_app <- lm( POWER_APP ~ CPUTI + DBTI + DBSU + KBYTES_TRANSFERRED, data = train )
PREDICTIVE_ANALYSIS <- predict(model_app)
result <-as.data.frame(PREDICTIVE_ANALYSIS)
END;

CALL ANAGAPPAN.USE_LM("POWER_CONSUMPTION","POWER_CONSUMPTION_OUT") WITH OVERVIEW;
SELECT*FROM "POWER_CONSUMPTION";

Have gone through the SAP HANA R Integration Guide, the example here works. Have checked calling in a standalone Rstudio with the data set it worked too, but when it comes to calling the function of R within SQL to the Rserver it fails.

来源:https://stackoverflow.com/questions/30724599/calling-r-function-within-sql-hana-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!