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

top_n() causes syntax error in sqlite #907

Closed
cpsievert opened this issue Jan 19, 2015 · 1 comment
Closed

top_n() causes syntax error in sqlite #907

cpsievert opened this issue Jan 19, 2015 · 1 comment
Labels
Milestone

Comments

@cpsievert
Copy link
Contributor

@cpsievert cpsievert commented Jan 19, 2015

library(dplyr)
tmp <- tempfile(fileext = ".sqlite3")
db <- src_sqlite(tmp, create = TRUE)
copy_to(db, mtcars, "mt_cars")
mt_cars <- tbl(db, "mt_cars") %>% top_n(20)
mt_cars

#> Error in sqliteSendQuery(con, statement, bind.data) : 
#>  error in statement: near "DESC": syntax error

This error seems to be the result of a bad WHERE clause

mt_cars$query
#> <Query> SELECT "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am", "gear", "carb"
#> FROM "mt_cars"
#> WHERE MIN_RANK("carb" DESC) <= 20.0
#> <SQLiteConnection>
@hadley
Copy link
Member

@hadley hadley commented Jan 20, 2015

Hmmmm, top_n() can't work with sqlite as currently written (and I don't know if it's possible at all using SQLite SQL), but it should throw an error.

@hadley hadley added this to the 0.5 milestone May 19, 2015
@hadley hadley closed this in 5503d91 Mar 7, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants