-
Notifications
You must be signed in to change notification settings - Fork 173
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
"ORDER BY is ignored in subqueries without LIMIT" without a subquery #562
Comments
I just verified that I get the same warning when the database driver is dplyr::show_query(query)
#> <SQL>
#> SELECT DISTINCT "EXTERNAL_PERMIT_NMBR"
#> FROM (echo_dfr.x_cwa_limits)
#> ORDER BY "EXTERNAL_PERMIT_NMBR"
result <- dplyr::pull(query)
#> Warning: ORDER BY is ignored in subqueries without LIMIT
#> i Do you need to move arrange() later in the pipeline or use window_order() instead? |
Could you please make a reprex, following the advice in https://dbplyr.tidyverse.org/articles/reprex.html? |
Ok, here's a reprex: library(dbplyr)
library(dplyr, warn.conflicts = FALSE)
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = "test",
host = "localhost",
user = ""
)
db <- copy_to(con, data.frame(x = 1:2), "test")
db2 <- db %>%
select(x) %>%
distinct() %>%
arrange(x)
db2 %>% collect()
#> # A tibble: 2 x 1
#> x
#> <int>
#> 1 1
#> 2 2
db2 %>% pull()
#> Warning: ORDER BY is ignored in subqueries without LIMIT
#> ℹ Do you need to move arrange() later in the pipeline or use window_order() instead?
#> [1] 1 2 Created on 2021-01-21 by the reprex package (v0.3.0.9001) The problem seems to be specifically with |
And the problem is that |
Fixed in e2c383a |
Wow. Thanks. I was going to find time today to make a reprex... |
With dplyr 1.0.3 and dbplyr 2.0.0, I create a query:
This works fine, and gives the SQL I expect:
So far, so good. But when I run the query, I get a warning about a subquery:
This doesn't seem to make sense, because the generated SQL doesn't include a subquery. But indeed the result isn't sorted:
If I submit the above SQL to Postgres directly using pool::dbGetQuery(), without using dbplyr, it works as expected:
The result is sorted, and I don't get a warning.
The text was updated successfully, but these errors were encountered: