Skip to content

top_n() causes syntax error in sqlite #907

@cpsievert

Description

@cpsievert
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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions