From b121cfad52ca372336e4d33521c47377a6f40f28 Mon Sep 17 00:00:00 2001 From: arunsrinivasan Date: Sat, 5 Mar 2016 21:42:11 +0100 Subject: [PATCH] Closes #1571. Not joins along with mult='first'/'last' is handled properly. --- R/data.table.R | 2 +- README.md | 2 ++ inst/tests/tests.Rraw | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/R/data.table.R b/R/data.table.R index d909661555..8a8ba6c432 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -627,7 +627,7 @@ chmatch2 <- function(x, table, nomatch=NA_integer_) { } } # Implementation for not-join along with by=.EACHI, #604 - if (notjoin && byjoin) { + if (notjoin && (byjoin || mult != "all")) { # mult != "all" needed for #1571 fix notjoin = FALSE if (verbose) {last.started.at=proc.time()[3];cat("not-join called with 'by=.EACHI'; Replacing !i with i=setdiff(x,i) ...");flush.console()} orignames = copy(names(i)) diff --git a/README.md b/README.md index 8f11c6aa71..cc2ae1b878 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ 39. `roll` argument handles -ve integer64 values correctly, [#1405](https://github.com/Rdatatable/data.table/issues/1405). Thanks @bryan4887. + 40. Not join along with `mult="first"` and `mult="last"` is handled correctly, [#1571](https://github.com/Rdatatable/data.table/issues/1571). + #### NOTES 1. Updated error message on invalid joins to reflect the new `on=` syntax, [#1368](https://github.com/Rdatatable/data.table/issues/1368). Thanks @MichaelChirico. diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 8b866c1cf5..af1f70fb35 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -7611,6 +7611,13 @@ if ("package:bit64" %in% search()) { test(1614.4, dt[.(val), roll=-Inf, on="x", rollends=TRUE], ans[, y:=c(5,10,10)]) } +# fix for #1571 +x = data.table(c(1,1,2,7,2,3,4,4,7), 1:9) +y = data.table(c(2,3,4,4,4,5)) +test(1615.1, x[!y, on="V1", mult="first"], data.table(V1=c(1,7), V2=INT(c(1,4)))) +test(1615.2, x[!y, on="V1", mult="last"], data.table(V1=c(1,7), V2=INT(c(2,9)))) +test(1615.3, x[!y, on="V1", mult="all"], data.table(V1=c(1,1,7,7), V2=INT(c(1,2,4,9)))) + ########################## # TODO: Tests involving GForce functions needs to be run with optimisation level 1 and 2, so that both functions are tested all the time.