Forum Stats

  • 3,752,279 Users
  • 2,250,483 Discussions
  • 7,867,775 Comments

Discussions

Problem with embedded R execution

3773366
3773366 Member Posts: 1
edited Sep 30, 2019 1:30PM in R Technologies

Hello

I'm working with ORE 1.5 from toad as SQL interface of embedded R scripting.My goal is to use embedded R script from SQL interface and its APIs to run k means without any transferring data, I mean the purpose is to execute in database-resident side instead of R local memory . To fulfill this, I've built a k means model with odmkmeans function by creating R script which is saved in database R repository. It is important to note that the data type of data columns is number.

my code is as below:

   BEGIN

  sys.rqScriptCreate('myKMeansModelBuild',

    'function(dat,ds_name) {

       km_mod <- NULL

       km_mod <- ore.odmKMeans( ~ NORM_VOI+NORM_DAT , dat, num.centers=3 , auto.data.prep = FALSE,iterations = 20)

       ore.save(km_mod, name = ds_name)

     }');

END;

and then, call it by following code:

select *

from table(rqTableEval(cursor(select * from SAMPLE_set3),

    cursor(select 1 as "ore.connect" , 'KM_DS_Build1' as "ds_name" from dual),

    'XML',

    'myKMeansModelBuild') );

But I get below error:

ORA-20000: RQuery error

Error in .ore.toNumber(x) :

  trying to get slot "desc" from an object (class "data.frame") that is not an S4 object

ORA-06512: at "RQSYS.RQTABLEEVALIMPL", line 112

ORA-06512: at "RQSYS.RQTABLEEVALIMPL", line 109

I couldn't understand what is the problem. Can anyone help to solve this ?

Thanks in advance.

Answers

  • Sherry Lamonica-Oracle
    Sherry Lamonica-Oracle Posts: 437 Employee
    edited Sep 30, 2019 1:30PM

    To start, I recommend verifying that the model and the save to the datastore execute outside of the SQL interface:

    km_mod <- ore.odmKMeans( ~ NORM_VOI+NORM_DAT , dat, num.centers=3 , auto.data.prep = FALSE,iterations = 20)

           ore.save(km_mod, name = ds_name)

    If so, does the following execute without error?

    select *

    from table(rqTableEval(cursor(select * from SAMPLE_set3),

        cursor(select 1 as "ore.connect" , 'KM_DS_Build1' as "ds_name" from dual),

        NULL,

        'myKMeansModelBuild') );