Issue using Rcpp package in R UDF
We are currently using Vertica 7.0.1 and are facing issues with one of the R UDFs we are writing. The Transform R UDF uses Rcpp package to source a C++ file. The following is the CPP file used:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
double meanC(NumericVector x) {
int n = x.size();
double total = 0;
for(int i = 0; i < n; ++i) {
total += x[i];
}
return total / n;
}
When I call this CPP file using sourceCpp command directly from Vertica R it works fine as follows:
sourceCpp("path/to/cpp/meanCPP.cpp")
However, when I call the sourceCpp function from inside a transform UDF, I get the following error:
Error: [Vertica][VJDBC](3399) ERROR: Failure in UDx RPC call InvokeProcessPartition(): Error calling processPartition() in User Defined Object [generateMean] at [/scratch_a/release/vbuild/vertica/OSS/UDxFence/RInterface.cpp:1244], error code: 0, message: Exception in processPartitionForR: [file io error: '/tmp/sourcecpp_ea83e081704/meanCPP.cpp']
SQLState: VP001
ErrorCode: 3399
Can someone help me with this error?
Thank you.
Ravi
0