Pivotal Knowledge Base


How to Install PL/R on Pivotal Greenplum


Pivotal Greenplum 4.3.x


This article will list the steps required to install a PL/R package on GPDB.

Download language extension or specific PL/R version for your database from the link, for more information on how to use the site to download the product, check the link.  



  • Running GPDB database cluster
  • Database superuser access
  • GPDB PL/R package bundle (Package name indicates .gppkg extension, example "plr-ossv8.3.0.15_pv2.1_gpdb4.3orca-rhel5-x86_64.gppkg")


Greenplum database provides a utility named gppkg which is used to manage extensions on Greenplum database. It is available by default once Greenplum database has been installed.

PL/R package provides:

  • R language interpreter installation (rpm)
  • PL/R language extension (rpm)
  • Spec file (yml)
[gpadmin@mdw]$ gppkg ~/plr-ossv8.3.0.15_pv2.1_gpdb4.3orca-rhel5-x86_64.gppkg --list
... deps deps/R-3.1.0-1.x86_64.rpm gppkg_spec.yml plr-2.1-2.x86_64.rpm [gpadmin@mdw ]$

Let's go through the steps required to install PL/R package and execute R language.

  • Step 1. Login to Greenplum database master server as gpadmin (superuser) and install PL/R package.
 [gpadmin@hawq-mdw ~]$ gppkg -i /tmp/database/plr-1.0-rhel5-x86_64.gppkg
 20140304:16:22:25:009588 gppkg:hawq-mdw:gpadmin-[INFO]:-Starting gppkg with args: -i /tmp/database/plr-1.0-rhel5-x86_64.gppkg
 20140304:16:22:47:009588 gppkg:hawq-mdw:gpadmin-[INFO]:-Completed local installation of plr-1.0-rhel5-x86_64.gppkg.
 20140304:16:22:48:009588 gppkg:hawq-mdw:gpadmin-[INFO]:-Please source your $GPHOME/greenplum_path.sh file and restart the database.
 You can enable PL/R by running createlang plr -d mydatabase.
 20140304:16:22:48:009588 gppkg:hawq-mdw:gpadmin-[INFO]:-plr-1.0-rhel5-x86_64.gppkg successfully installed.
  • Step 2. Source greenplum_path.sh file to bring newly added environment variables related to R (R_HOME and LD_LIBRARY_PATH) 

Source Greenplum path.

[gpadmin@hawq-mdw R-2.13.0]$ source /usr/local/greenplum-db/greenplum_path.sh 
  • Step 3. Restart the database
[gpadmin@hawq-mdw ~]$ gpstop -r 
  • Step 4. Create PLR language in the required database
[gpadmin@hawq-mdw R-2.13.0]$ createlang plr -d gpdb
[gpadmin@hawq-mdw R-2.13.0]$
  • Step 5. Verify by using a PL/R provided function:
gpdb=# CREATE OR REPLACE FUNCTION r_norm(n integer, mean float8, std_dev float8) RETURNS float8[ ] AS $$ x<-rnorm(n,mean,std_dev); return(x) $$ LANGUAGE 'plr';

gpdb=# select r_norm(10, 0, 1);

(1 row)

gpdb=# CREATE TABLE test_norm_var AS SELECT id, r_norm(10,0,1) as x FROM (SELECT generate_series(1,30:: bigint) AS ID) foo DISTRIBUTED BY (id);
  • Step 6. Configure R if necessary

You could need to make few modifications in Rscript file to use R language, else you can get an error like below:

[gpadmin@hawq-mdw bin]$/usr/local/greenplum-db/ext/R-2.13.0/bin/R
 WARNING: ignoring environment value of R_HOME
 ./R: line 227: /opt/releng/tools/R-Project/R/2.13.0/rhel5_x86_64/lib64/R/etc/ldpaths: No such file or directory


Step 1: Edit R script

[gpadmin@hawq-mdw bin]$ vi /usr/local/greenplum-db/ext/R-2.13.0/bin/R

Step 2: Comment out existing R_HOME_DIR


Step 3: Add R_HOME_DIR variable point to Greenplum installation location (It might differ based on your installation of HAWQ / Greenplum, so change it appropriately)

export R_HOME_DIR=/usr/local/greenplum-db/ext/R-2.13.0/lib64/R

Additional Information

Pivotal internal employees reference MPP-22802.


  • Avatar

    This is helpful.

  • Avatar

    Thanks this is helpful.

Powered by Zendesk