-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
as.data.frame() does not respect column order for DB backends #3216
Labels
bug
an unexpected problem or unintended behavior
Comments
JohnMount
changed the title
Column names mis-ordered when passing dbplyr data to knitr::kable()
as.data.frame() does not respect column order
Nov 21, 2017
JohnMount
changed the title
as.data.frame() does not respect column order
as.data.frame() does not respect column order for DB backends
Nov 21, 2017
Minimal reprex library(dplyr, warn.conflicts = FALSE)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
df <- data.frame(x = 1, y = 2)
db <- copy_to(con, df)
db2 <- mutate(db, x1 = x + 1, y = x1 + y)
colnames(db2)
#> [1] "x" "y" "x1"
colnames(collect(db2))
#> [1] "x" "x1" "y" Due to |
krlmlr
added a commit
to krlmlr/dbplyr
that referenced
this issue
Dec 27, 2017
- closes tidyverse/dplyr#3216 - closes tidyverse/dplyr#3222 - closes tidyverse/dplyr#3223
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
as.data.frame()
does not respect column order for DB backends (or at least is not stable, or does not use the same column order ascolnames()
). A lot of code depends on column order, so I would consider this a bug (regardless of the documented or not-documented invariants ofas.data.frame()
). The issue occurs with more than one DB data provider (RSQlite
andSparklyr
) and seems to change if acompute()
is issued.With the issue any code of the following form may be wrong.
As it will not be equivalent to:
knitr
currently has such code, and is producing erroneous reports.Right or wrong I think users expect stable column order.
Included
reprex
is long as the issue is subtle, yet important (and we need to establish issue on more than one backend).The text was updated successfully, but these errors were encountered: