Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra arguments in explain() do not reach backend specific sql_query_explain -method #783

Closed
rsund opened this issue Feb 18, 2022 · 1 comment · Fixed by #800
Closed

Comments

@rsund
Copy link
Contributor

rsund commented Feb 18, 2022

Postgres-backend includes a format argument to the sql_query_explain -method. However, that argument never survives to the function, and default value is always used. This is very restrictive for the backends that would benefit for passing arguments to the method.

To demonstrate the issue, the following reprex changes the sql_query_explain -method of SQLiteConnection so that the value of the argument becomes visible.

library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)

# Adding format argument (from Postgres explain) to SQLite explain
sql_query_explain.SQLiteConnection <- function(con, sql, format = "text", ...) {
  dbplyr:::cat_line("Parameter 'format' with value: ", format)
  build_sql("EXPLAIN QUERY PLAN ", sql, con = con)
}
assignInNamespace("sql_query_explain.SQLiteConnection", sql_query_explain.SQLiteConnection, ns = "dbplyr")

con = DBI::dbConnect(RSQLite::SQLite(), ":memory:")
df <- copy_to(con, tibble(x=1))
df %>% explain(format="json") # Value below should be: json
#> <SQL>
#> SELECT *
#> FROM `tibble(x = 1)`
#> 
#> <PLAN>
#> Parameter 'format' with value: text
#>   id parent notused             detail
#> 1  2      0       0 SCAN tibble(x = 1)
DBI::dbDisconnect(con)

Created on 2022-02-18 by the reprex package (v2.0.1.9000)

@mgirlich
Copy link
Collaborator

Thanks, explain() now passes ... to sql_query_explain()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants