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

Sort order of NAs #201

Closed
krlmlr opened this issue Jan 3, 2019 · 3 comments
Closed

Sort order of NAs #201

krlmlr opened this issue Jan 3, 2019 · 3 comments
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@krlmlr
Copy link
Member

krlmlr commented Jan 3, 2019

NAs sort first in (some) SQL databases (at least MySQL, SQLite and SQL Server), but last in tibbles and PostgreSQL. I wonder what's the best way to document this, we don't seem to have ?dbplyr::arrange yet.

library(tidyverse)

dbplyr::memdb_frame(a = c(1, NA)) %>%
  arrange(a)
#> # Source:     table<szlvekywfo> [?? x 1]
#> # Database:   sqlite 3.22.0 [:memory:]
#> # Ordered by: a
#>       a
#>   <dbl>
#> 1    NA
#> 2     1

tibble(a = c(1, NA)) %>%
  arrange(a)
#> # A tibble: 2 x 1
#>       a
#>   <dbl>
#> 1     1
#> 2    NA

dbplyr::memdb_frame(a = c(1, NA)) %>%
  arrange(if_else(is.na(a), 1, 0), a)
#> # Source:     table<liromxakig> [?? x 1]
#> # Database:   sqlite 3.22.0 [:memory:]
#> # Ordered by: if_else(is.na(a), 1, 0), a
#>       a
#>   <dbl>
#> 1     1
#> 2    NA

Created on 2019-01-03 by the reprex package (v0.2.1)

@batpigandme batpigandme added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jan 8, 2019
@mkearney
Copy link
Contributor

DIBS

@hadley
Copy link
Member

hadley commented Jan 19, 2019

@mkearney just in case it's not obvious, you'll need to document arrange.tbl_lazy since currently it's not documented. The closest existing template would be copy_to.src_sql.

@yutannihilation
Copy link
Member

FYI, dplyr::arrange() now documents about NA, which is yet different from databases tidyverse/dplyr#4083.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

5 participants