I am just beginning to discover all the advantages of using R & monetDB/monetDBLite package - great stuff!
I was curious however if it's possible to use a custom defined function in dplyr's mutate() i.e.
# Connect to monetDBLite
db <- src_monetdb(embedded = db.dir)
data <- tbl(db, "my.table")
# Try to make a new column using custom defined function
data %>% group_by(colX) %>% mutate(NewCol = customFunc())
Results in the following error:
Error in .local(conn, statement, ...) :
Unable to execute statement 'SELECT colA colB colC...'.
Server says 'ParseException:SQLparser:SELECT: no such operator 'customFunc''.
It seems like the SQL parser has a problem finding the custom function. Am I overseeing something (declare R code in a SQL function definition etc.) ? Is it possible to use custom defined functions with the monetDBLite package like this?
Since @Hannes answered my question in the comments - i'm adding it here with some other stuff i picked up:
one can use the basic
dplyrverbs (select,filter,group_by&mutate) in conjunction with some other "basic"Rfunctions. There is a list of the supported functions, and more on this, in thedplyrdatabases vignette under the section "SQL translation". So, using the example from my question above - one can do:data %>% group_by(col_x) %>% mutate(new_col = log10(some_old_col)).MonetDBLitedoes not support UDFs (e.g. my question here - if it's possible to use my UDF inside amutatecall) ...... however the "full"
MonetDBdoes support used defined functions to be sent to the db for computation. It is all well explained on their homepage.