Skip to content

semi_join does not coerce y to lazy_dt#322

Description

@dakvid

Version 1.2.0 has some great new features, but has broken semi_join (or all my uses of it anyway 馃榾) as the second argument is no longer coerced from a data.table to a lazy_dt. The error message didn't make any sense until I came across #278 but that helped me deduce what was happening.

library(dplyr, warn.conflicts = FALSE)      # 1.0.7
library(data.table, warn.conflicts = FALSE) # 1.14.2
library(dtplyr, warn.conflicts = FALSE)     # 1.2.0

x <- data.table(a = 1:4, b = c(1:2, 1:2))
y <- data.table(b = 2L)

inner_join(x, y)
#> Joining, by = "b"
#> Source: local data table [2 x 2]
#> Call:   `_DT1`[`_DT2`, on = .(b), nomatch = NULL, allow.cartesian = TRUE]
#> 
#>       a     b
#>   <int> <int>
#> 1     2     2
#> 2     4     2
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
full_join(x, y)
#> Joining, by = "b"
#> Source: local data table [4 x 2]
#> Call:   setcolorder(merge(`_DT3`, `_DT4`, all = TRUE, by.x = "b", by.y = "b", 
#>     allow.cartesian = TRUE), 2:1)
#> 
#>       a     b
#>   <int> <int>
#> 1     1     1
#> 2     3     1
#> 3     2     2
#> 4     4     2
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
anti_join(x, y)
#> Joining, by = "b"
#> Source: local data table [2 x 2]
#> Call:   `_DT5`[!`_DT6`, on = .(b)]
#> 
#>       a     b
#>   <int> <int>
#> 1     1     1
#> 2     3     1
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
semi_join(x, y)
#> Error in step_join(x, y, on = by, style = "semi"): is_step(y) is not TRUE
semi_join(x, y %>% lazy_dt())
#> Joining, by = "b"
#> Source: local data table [2 x 2]
#> Call:   `_DT8`[unique(`_DT8`[`_DT9`, which = TRUE, nomatch = NULL, on = .(b)])]
#> 
#>       a     b
#>   <int> <int>
#> 1     2     2
#> 2     4     2
#> 
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions