Controlling script invocations

One of the most common uses of limiting external script invocations to a single thread when using Kognitio external scripts is to obtain information about what is installed on the Kognitio nodes. The free statistical computing software environment R has lots of pre-built packages that can be easily installed and utilized from Kognitio. Within R there is a function called installed.packages that will list information about which R packages are installed on a system.

Example: Obtaining a list of R packages installed on Kognitio

This external script lists the packages installed on one of the Kognitio nodes or every node if PER NODE is uncommented to see the packages on every node:

CREATE EXTERNAL SCRIPT my_schema.R_package_info ENVIRONMENT rscript
SENDS(node_name varchar(100),connector_num int,package_name varchar(100),version_no varchar(100),libpath VARCHAR(100),pkg_priority varchar(20))
    #Get hostname and connector number
    cnum<- Sys.getenv("WX2_CONNECTOR_NUM")
    hname <- toString(["nodename"])[1,1])
    #Get the package names,version and priority (base,recommended,NA)
    #Drop row names
    rownames(pkgs) <- NULL
    #Print out result

This external script RECEIVES no data from Kognitio but simply SENDS the R package information back to Kognitio when the following SQL is submitted:

EXTERNAL SCRIPT R_package_info;

The results (from Kognitio Console) are displayed below and include the package, where it is stored on the system, the version number and the priority of the package. A package with a priority value equal to “base” indicates the package is part of the standard R install.

R Packages installed on a Kognitio node access via an external script call