We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


type changes when vertica pass data to R — Vertica Forum

type changes when vertica pass data to R

I am passing a table of data (1 column) of type varchar to R, and in the R i printed it out, but i found all the data changed into numeric value. Following is the declaration of the function: testReturn <- function(wf) { result <- matrix(c('2'), ncol=1, nrow=nrow(wf)) #create a matrix with 1 column of varchar type to take the data. result[,1] <- wf[,1] result } testReturnFactory <- function() { list(name=testReturn,udxtype=c("transform"),intype=c("varchar"),outtype=c("varchar"),outnames=c("MSISDN")) } Following is my testing sql: drop library TestReturnLib cascade; create library TestReturnLib as '/home/dbadmin/IP/testReturn.R' language 'R'; create transform function TestReturn as name 'testReturnFactory' library TestReturnLib; drop table TestReturn; create table TestReturn("MSISDN" varchar(30)); insert into TestReturn (MSISDN) values('123'); insert into TestReturn (MSISDN) values('124'); insert into TestReturn (MSISDN) values('125'); drop table TestReturnResult; select * into TestReturnResult from (select testReturn(MSISDN) over() from TestReturn) as dummy; select * from TestReturnResult; The result is very wierd: MSISDN -------- 1 2 3 not the expected MSISDN -------- 123 124 125

Comments

  • R: testReturn <- function(wf) { result <- matrix(c('2'), ncol=1, nrow=nrow(wf)) result[,1] <- wf[,1] result } testReturnFactory <- function() { list(name=testReturn,udxtype=c("transform"),intype=c("varchar"),outtype=c("varchar"),outnames=c("MSISDN")) }
  • testReturn <- function(wf){ result <- matrix(c('2'), ncol=1, nrow=nrow(wf)) result[,1] <- wf[,1] result } testReturnFactory <- function(){ list(name=testReturn,udxtype=c("transform"),intype=c("varchar"),outtype=c("varchar"),outnames=c("MSISDN")) }
  • testReturn == function(wf){ result <- matrix(c('2'), ncol=1, nrow=nrow(wf)) result[,1] <- wf[,1] result } testReturnFactory == function(){ list(name=testReturn,udxtype=c("transform"),intype=c("varchar"),outtype=c("varchar"),outnames=c("MSISDN")) }

Leave a Comment

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