Forum Stats

  • 3,733,004 Users
  • 2,246,671 Discussions
  • 7,856,459 Comments

Discussions

ODM SQL Node: Using R scripts

hvaleria
hvaleria Member Posts: 6
edited October 2014 in Machine Learning

Is there a way to use R scripts in an ODM workflow without defining the output?

So that ODM identifies the number and types of columns from the output.

Currently I use R scripts as follows:

If there are n1 character columns and n2 numeric columns in the output from the script then I use something like:

    

select * from table(rqTableEval

  ( CURSOR (

  SELECT

   *

  FROM

  TABLE1

   )

   , -- Input Cursor

  cursor(select * from dual)

  ,           -- Param Cursor

  'select

   cast(null as varchar2(100)) char_col1,

   cast(null as varchar2(100)) char_col2,

   ... ,

   cast(null as varchar2(100)) char_coln1,

   0 as num_col1,

   0 as num_col2,

   ... ,

   0 as num_coln2

   from dual',      -- Output Definition

   'rscript' -- R Script

  ))

Sean S. Han

Answers

  • Denny Wong-Oracle
    Denny Wong-Oracle Member Posts: 183

    If your R script produces an output (e.g. XML, PNG, data frame), then you should specify the output accordingly.

    For example, if your R script produces a data frame output, you should use the SELECT statement to specify the output data types.

    However, If your R script doesn't return any object, you can specify a NULL value.

    Please refer to the "SQL Interface for Embedded R Execution" in the following doc for more info:

    Using Oracle R Enterprise Embedded R Execution

    Sean S. Hanhvaleria
This discussion has been closed.