IMSMWU/RClickhouse

dbReadTable fails

Closed this issue · 1 comments

dbReadTable fails, but subquery works, which is quite strange...

For example dbGetQuery(conn, "SELECT * from iris_df") works and also dbGetQuery(conn, paste0("SELECT * FROM ", "iris_df")) works. But the same code wrapped within a method does not work:

#' @export
#' @rdname ClickhouseConnection-class
setMethod("dbReadTable", "ClickhouseConnection", function(conn, name, ...) {
  dbGetQuery(conn, paste0("SELECT * FROM ", name))
})
> dbReadTable(conn, "iris_df")
Note: method with signature ‘DBIConnection#character’ chosen for function ‘dbReadTable’,
 target signature ‘ClickhouseConnection#character’.
 "ClickhouseConnection#ANY" would also be valid
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"character", "missing"’
> dbReadTable(conn, "iris_df")
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"character", "missing"’
``
v5r commented

The problem here is that the provided implementation of dbReadTable is not even used, since the signature is not correct (must be c("ClickhouseConnection", "character") rather than just "ClickhouseConnection"), which messes up the method selection in apparently unpredictable ways.

I'm not sure how to tell when a signature is sufficiently precise, so it's probably best to provide types for all required arguments.