-
Notifications
You must be signed in to change notification settings - Fork 186
Closed
Description
Function dbplyr::tbl_sql() has parameter vars, but I am unable to pass it from dplyr::tbl.DBIConnection(), because ... are ignored in dbplyr::tbl.src_dbi().
Here is a simple test:
> trace(dbplyr:::db_query_fields.DBIConnection)
> class(con)
[1] "Microsoft SQL Server"
attr(,"package")
[1] ".GlobalEnv"
> tbl(con, sql("select id, name from test"))
trace: db_query_fields.DBIConnection(con, ...)
# Source: SQL [?? x 2]
# Database: Microsoft SQL Server 12.00.2000[xxxx]
id name
<int> <chr>
1 1 test1
2 2 test2
> tbl(con, sql("select id, name from test"), vars = c("id", "name"))
trace: db_query_fields.DBIConnection(con, ...)
# Source: SQL [?? x 2]
# Database: Microsoft SQL Server 12.00.2000[xxxx]
id name
<int> <chr>
1 1 test1
2 2 test2
Note, that db_query_fields() is called in both cases.
Parameter vars can be helpful not just to save one request to database, but also to be able to fetch hidden SQL Server temporal tables' period columns, which are not returned by db_query_fields(). For now, my workaround is to use dbplyr::tbl_sql() directly.
I propose to modify tbl.dbi_src() to pass the dots down to tbl_sql:
tbl.src_dbi <- function(src, from, ...) {
subclass <- class(src$con)[[1]] # prefix added by dplyr::make_tbl
tbl_sql(c(subclass, "dbi"), src = src, from = from, ...)
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels