A SQL query that includes an R function may fail with : "R interpreter parse error".
The master log will show:
2016-06-02 11:30:06.226608 EDT,"212456758","master",p320737,th-1043842848,"3.39.77.9","54463",2016-06-02 10:49:07 EDT,46417013,con127349,cmd7,seg-1,,,x46417013,sx1,"ERROR","22000","R interpreter parse error (seg139 segement1.domain:41003 pid=467112)","
R parse error caught in ""PLR9437558 <- function(arg1,arg2) {
library(data.table)
# library(lubridate)
library(dplyr)
temp1 <- arg2
temp1[temp1 == -9999] <- NA
temp2[temp2 == -9999] <- NA
temp1$frame_offset <- temp2
rm(temp2)
....
This error could be caused by one of two things:
1. Use "tr" to remove any windows characters that may be present in the function with a command similar to this:
tr -d '\15\32' < winfile.txt > unixfile.txt
2. Review the code for syntax errors, using pgadmin may help as it will highlight syntax errors in yellow in the code viewer. Some examples of syntax errors are:
min_values <- apply(tempo1[,masada_vars], 2, min(x, var.test = TRUE)b) The "(" and "[" are never closed for this line of code:
test02_example <- apply(test1[,pe3. Once the syntax errors are corrected, reload the function and re-run it.