From f9e21dd3e46fa193e43dca1edfd5920d8cb3d414 Mon Sep 17 00:00:00 2001 From: jangorecki Date: Thu, 2 Apr 2020 19:56:06 +0100 Subject: [PATCH 1/2] join, which=NA, fixes #4303 --- NEWS.md | 2 ++ R/data.table.R | 2 +- inst/tests/tests.Rraw | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 71fd76aa6..cccee3eaa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -107,6 +107,8 @@ unit = "s") 12. `rbindlist` no longer errors when coercing complex vectors to character vectors, [#4202](https://github.com/Rdatatable/data.table/issues/4202). Thanks to @sritchie73 for reporting and the PR. +13. Using `which = NA` during join operation could eventually yield incorrect row indices, [#4303](https://github.com/Rdatatable/data.table/issues/4303). Thanks to @cbilot for reporting. + ## NOTES 0. Retrospective license change permission was sought from and granted by 4 contributors who were missed in [PR#2456](https://github.com/Rdatatable/data.table/pull/2456), [#4140](https://github.com/Rdatatable/data.table/pull/4140). We had used [GitHub's contributor page](https://github.com/Rdatatable/data.table/graphs/contributors) which omits 3 of these due to invalid email addresses, unlike GitLab's contributor page which includes the ids. The 4th omission was a PR to a script which should not have been excluded; a script is code too. We are sorry these contributors were not properly credited before. They have now been added to the contributors list as displayed on CRAN. All the contributors of code to data.table hold its copyright jointly; your contributions belong to you. You contributed to data.table when it had a particular license at that time, and you contributed on that basis. This is why in the last license change, all contributors of code were consulted and each had a veto. diff --git a/R/data.table.R b/R/data.table.R index 9292ee940..b815078fe 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -467,7 +467,7 @@ replace_dot_alias = function(e) { # If using secondary key of x, f__ will refer to xo if (is.na(which)) { w = if (notjoin) f__!=0L else is.na(f__) - return( if (length(xo)) fsort(xo[w], internal=TRUE) else which(w) ) + return( if (length(xo) && notjoin) fsort(xo[w], internal=TRUE) else which(w) ) } if (mult=="all") { # is by=.EACHI along with non-equi join? diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 7cc6819e8..752fd7763 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -16846,3 +16846,16 @@ A = data.table(A=c(complex(real = 1:3, imaginary=c(0, -1, 1)), NaN)) test(2138.3, rbind(A,B), data.table(A=c(as.character(A$A), B$A))) A = data.table(A=as.complex(rep(NA, 5))) test(2138.4, rbind(A,B), data.table(A=c(as.character(A$A), B$A))) + +# which = NA yields incorrect results #4303 +customers = data.table(ID = c( + 108924851L, 105257553L, 118054200L, 108365953L, + 116642294L, 100419961L, 115677488L, 100405475L, + 119246064L, 100383251L +)) +orders = data.table(ID = c(105257553L)) +test(2139.1, customers[orders, on = .(ID), which = NA], integer()) +orders = data.table(ID = c(105257554L)) +test(2139.2, customers[orders, on = .(ID), which = NA], 1L) +orders = data.table(ID = c(105257554L, 108924851L)) +test(2139.3, customers[orders, on = .(ID), which = NA], 1L) From 32fcdc173743dc8ffc7c74f9ce3c3c1f509f8ed5 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 3 May 2020 13:37:52 +0800 Subject: [PATCH 2/2] remove dSYM file & ignore henceforth --- .gitignore | 1 + a.out.dSYM/Contents/Info.plist | 20 -------------------- a.out.dSYM/Contents/Resources/DWARF/a.out | Bin 8802 -> 0 bytes 3 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 a.out.dSYM/Contents/Info.plist delete mode 100644 a.out.dSYM/Contents/Resources/DWARF/a.out diff --git a/.gitignore b/.gitignore index 35a25bc08..db9ca83ee 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ vignettes/plots/figures *.o *.so *.dll +*.dSYM *~ .DS_Store diff --git a/a.out.dSYM/Contents/Info.plist b/a.out.dSYM/Contents/Info.plist deleted file mode 100644 index 3679a65b9..000000000 --- a/a.out.dSYM/Contents/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleIdentifier - com.apple.xcode.dsym.a.out - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - dSYM - CFBundleSignature - ???? - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/a.out.dSYM/Contents/Resources/DWARF/a.out b/a.out.dSYM/Contents/Resources/DWARF/a.out deleted file mode 100644 index 3f10aad029c812c72ab7195234668d11aa4e3716..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8802 zcmeI2&rcIU6vt;X5u_Dzu$cJ?RTco-QnH0&p$RW zrbQWJ-H^HoCi3uzM3H@1*Ur$20 z3z`Fv#vpNiF*lmOmY=!+jgSdes4v_^&OLDCd?tT&X6>k$57%pDcuO%z9W=QdU}*l2@%8j$St1FfU8-;qL*oY*G~KW&xhJSZ(Ib5>M{i**1B4O?T!@x9NUe z;z1$IZIeeIgC^b+;!P0mNt-;~Fly#}^Lnfh?*#Ey+T^+LSwIV~$IxMazZhbav7tRw zS*PG!uU2i7i^Xlhdq6z7Zy)>(uc{Zq@huZ?AH}oWCQodZ7V&){-UZ@)X_HqmZWeG# zIKC|W;nJXA#+ThoU{xpulmbctrGQdEDWDYiPZYq%j4fJ^xLf>Qv`w@blh42S4XRw? z=7L$MdnP=O>P2`S>#AZivfI* zusU=aT9)IVw;yVZ_=m6(8$43TMcX6vN8N?Y9S_iIMoR_;}w59EGX-STvE1 z$Hf6`!G=@FI(V#3kc)4>rz L58_~?