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

mutate(var = NULL) results in error #129

Closed
rossellhayes opened this issue Nov 24, 2019 · 1 comment
Closed

mutate(var = NULL) results in error #129

rossellhayes opened this issue Nov 24, 2019 · 1 comment

Comments

@rossellhayes
Copy link

rossellhayes commented Nov 24, 2019

Within regular dplyr, setting a variable to NULL removes that column:

library(dplyr, warn.conflicts = FALSE)

tibble(a = 1:3, b = 4:6) %>%
  mutate(a = NULL)
#> # A tibble: 3 x 1
#>       b
#>   <int>
#> 1     4
#> 2     5
#> 3     6

Following these same steps within a lazy_dt with dtplyr produces an error:

library(dtplyr)
library(dplyr, warn.conflicts = FALSE)

tibble(a = 1:3, b = 4:6) %>%
  lazy_dt() %>%
  mutate(a = NULL) %>%
  as_tibble()
#> Error: Invalid input
@rossellhayes rossellhayes changed the title mutate(var = NULL) result in error mutate(var = NULL) results in error Nov 25, 2019
@MichaelChirico
Copy link
Contributor

I think we're supposed to end up in the is_symbol branch of dt_squash? But rlang:::is_symbol(NULL) returns FALSE despite appearing like it's intended to return TRUE?

is_symbol
function (x, name = NULL) 
{
    # typeof(NULL) is "NULL", but is_null is returning
    #   x == R_NilValue from C, so I'm not sure how we'd
    #   get to the latter branch without returning from this one
    if (typeof(x) != "symbol") {
        return(FALSE)
    }
    if (is_null(name)) {
        return(TRUE)
    }
    as_string(x) %in% name
}

@hadley hadley closed this as completed in a69dd3f Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants