-
Notifications
You must be signed in to change notification settings - Fork 174
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
Median translated incorrectly for SQLite #357
Comments
The problem is that data <- data.frame(x = c(1, 2))
db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
data <- dplyr::copy_to(db, data)
dbplyr::sql_render(dplyr::summarize(data, x = mean(x)))
#> Warning: Missing values are always removed in SQL.
#> Use `mean(x, na.rm = TRUE)` to silence this warning
#> This warning is displayed only once per session.
#> <SQL> SELECT AVG(`x`) AS `x`
#> FROM `data`
dplyr::summarize(data, x = mean(x))
#> # Source: lazy query [?? x 1]
#> # Database: sqlite 3.29.0 [:memory:]
#> x
#> <dbl>
#> 1 1.5
dbplyr::sql_render(dplyr::summarize(data, x = median(x)))
#> <SQL> SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY `x`) AS `x`
#> FROM `data`
dplyr::summarize(data, x = median(x))
#> Error: near "(": syntax error Created on 2019-10-18 by the reprex package (v0.3.0) |
My original code and error was with MariaDB, I just didn't know how to do a reprex for that. But it looks like you are right which is why my error messages were different. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@GrayAlex49 MariaDB does support
|
This comment has been minimized.
This comment has been minimized.
The original bug was about MySQL, but no reprex was provided. There seems to be a separate bug with SQLite where it's using |
Fixed in a79c441 |
Using dplyr to work with data from a database, the median function does not seem to be translating correctly. Mean works as expected but median does not. I'm using a mysql database but can recreate the problem in sqlite.
This error is rather unhelpful, on my actual data I was getting something like
The text was updated successfully, but these errors were encountered: