The Vertica Forum recently got a makeover! Let us know what you think by filling out this short, anonymous survey.

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

 

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.