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

dplyr::n() does not work on databases #197

Closed
JohnMount opened this issue Dec 31, 2018 · 2 comments
Closed

dplyr::n() does not work on databases #197

JohnMount opened this issue Dec 31, 2018 · 2 comments
Labels
Milestone

Comments

@JohnMount
Copy link

@JohnMount JohnMount commented Dec 31, 2018

The dplyr::n() notation suggested in https://github.com/tidyverse/dplyr/blob/master/NEWS.md#breaking-changes does not work on database handles.

packageVersion("dplyr")
#> [1] '0.7.8'

# works
dplyr::summarize(data.frame(x = 1), count = dplyr::n())
#>   count
#> 1     1

# fails
db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
t <- dplyr::copy_to(db, data.frame(x = 1), "d")
dplyr::summarize(t, count = dplyr::n())
#> Error: This function should not be called directly

Created on 2018-12-31 by the reprex package (v0.2.1)

See also tidyverse/dplyr#4062 .

@hadley hadley transferred this issue from tidyverse/dplyr Dec 31, 2018
@hadley
Copy link
Member

@hadley hadley commented Dec 31, 2018

Moved to dbplyr since that is where the problem lies.

@hadley
Copy link
Member

@hadley hadley commented Jan 2, 2019

Minimal reprex:

mf <- dbplyr::memdb_frame(x = 1:10)
dplyr::summarise(mf, n = dplyr::n())
#> Error: This function should not be called directly
#> Backtrace:
#>     █
#>  1. ├─dplyr::summarise(mf, n = dplyr::n())
#>  2. ├─dbplyr:::summarise.tbl_lazy(mf, n = dplyr::n())
#>  3. │ └─dbplyr::partial_eval(dots, vars = op_vars(.data))
#>  4. │   ├─rlang::switch_type(...)
#>  5. │   └─dbplyr:::map(call, partial_eval, vars = vars, env = env)
#>  6. │     └─base::lapply(.x, .f, ...)
#>  7. │       └─dbplyr:::FUN(X[[i]], ...)
#>  8. │         ├─rlang::switch_type(...)
#>  9. │         └─dbplyr::partial_eval(f_rhs(call), vars, f_env(call))
#> 10. │           ├─rlang::switch_type(...)
#> 11. │           └─dbplyr:::lang_partial_eval(call, vars, env)
#> 12. │             ├─rlang::switch_lang(...)
#> 13. │             └─rlang::eval_bare(call, env)
#> 14. └─dplyr::n()

Created on 2019-01-02 by the reprex package (v0.2.1)

@hadley hadley closed this in 308f35e Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants