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

slice() fails on tbl_sqlite #720

Closed
vjcitn opened this issue Oct 23, 2014 · 4 comments
Closed

slice() fails on tbl_sqlite #720

vjcitn opened this issue Oct 23, 2014 · 4 comments
Assignees
Milestone

Comments

@vjcitn
Copy link

@vjcitn vjcitn commented Oct 23, 2014

if an intrinsic limitation man page should clarify

> mtcars %>% slice(1:4)
   mpg cyl disp  hp drat    wt  qsec vs am gear carb
1 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
2 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
3 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
4 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
> con = dbConnect(dbDriver("SQLite"), "/tmp/cars2.sqlite")
> dbWriteTable(con, "carsdb", mtcars)
[1] TRUE
> src_sqlite("/tmp/cars2.sqlite") %>% tbl("carsdb") %>% slice(1:4)
Error in UseMethod("slice_") : 
  no applicable method for 'slice_' applied to an object of class "c('tbl_sqlite', 'tbl_sql', 'tbl')"

Enter a frame number, or 0 to exit   

1: src_sqlite("/tmp/cars2.sqlite") %>% tbl("carsdb") %>% slice(1:4)
2: withVisible(eval(e, env))
3: eval(e, env)
4: eval(expr, envir, enclos)
5: slice(`src_sqlite("/tmp/cars2.sqlite") %>% tbl("carsdb")`, 1:4)
6: slice_(.data, .dots = lazyeval::lazy_dots(...))
@hadley hadley added this to the 0.3.1 milestone Oct 30, 2014
@hadley hadley self-assigned this Oct 30, 2014
@hadley
Copy link
Member

@hadley hadley commented Oct 30, 2014

Yeah, all we can do here is document it. You'll never be able to slice() a sql data source.

@vjcitn
Copy link
Author

@vjcitn vjcitn commented Oct 30, 2014

couldn't you set this up with an offset and a limit?

On Thu, Oct 30, 2014 at 5:22 PM, Hadley Wickham notifications@github.com
wrote:

Yeah, all we can do here is document it. You'll never be able to slice()
a sql data source.


Reply to this email directly or view it on GitHub
#720 (comment).

@hadley
Copy link
Member

@hadley hadley commented Nov 19, 2014

@vjcitn that's only one type of slice - you can also do slice(mtcars, seq(1, n(), by = 2)). If you want to do a similar transformation with sql, you could use filter() + row_number() but it's not obvious that it's a meaningful operation because rows in SQL have no intrinsic order.

@lock
Copy link

@lock lock bot commented Sep 16, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Sep 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants