I am new to the world of UDF w/R and Vertica. I have the following R code:
Code: Select all
betaFunction <- function(client, domain, user_name, ptSeen, avgATPP, avgOTPP, avgDTPP, percentCPOE, percentEDOC)
{
sub <- subset((percentEDOC > .2) & (percentCPOE > .2) & (avgATPP < .06), select=c(client, domain, user_name, ptSeen, avgATPP, avgOTPP, avgDTPP, percentCPOE, percentEDOC))
cooksreg <- lm(sub$avgATPP~sub$ptSeen)
cook <- cooks.distance(cooksreg)
df <- data.frame(sub,cook)
sub1 <- subset(df, select=c(client,domain,user_name,ptSeen,avgATPP,avgOTPP,avgDTPP,percentCPOE,percentEDOC),cook<.05)
cpoereg <- lm(sub1$avgOTPP~sub1$percentCPOE)
edocreg <- lm(sub1$avgDTPP~sub1$percentEDOC)
betacpoe <- coef(cpoereg)[2]
betaedoc <- coef(edocreg)[2]
print(c(betacpoe,betaedoc),digits=5)
}
betaFactory <- function()
{
list(name=betaFunction,udxtype=c("transform"),intype=c("varchar","varchar","varchar","int","float","float","float","float","float"),outtype=c("float","float"),outnames=c("cpoeBeta","edocBeta"))
}
Code: Select all
CREATE LIBRARY betaFunctionLib AS '/home/vertica/betaFunction.R' LANGUAGE 'R';
CREATE TRANSFORM FUNCTION betaFunction AS NAME 'betaFactory' LIBRARY betaFunctionLib;
Error: [Vertica][VJDBC](3399) ERROR: Failure in UDx RPC call InvokeProcessPartition(): Error calling processPartition() in User Defined Object [betaFunction] at [/scratch_a/release/vbuild/vertica/OSS/UDxFence/RInterface.cpp:1244], error code: 0, message: Exception in processPartitionForR: ['percentEDOC' is missing]
SQLState: VP001
ErrorCode: 3399
Changed the betaFunction (client, domain ...) to betaFunction(x) and then referenced it the R code like such x[,1] . . . this seemed to help, but now I must make a few more adjustments to get it working.
thanks!