Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@

31. Fixed a bug on Windows where `data.table`s containing non-UTF8 strings in `key`s were not properly sorted, [#2462](https://github.com/Rdatatable/data.table/issues/2462), [#1826](https://github.com/Rdatatable/data.table/issues/1826) and [StackOverflow](https://stackoverflow.com/questions/47599934/why-doesnt-r-data-table-support-well-for-non-ascii-keys-on-windows). Thanks to @shrektan for reporting and fixing.

32. `x.` prefixes during joins sometimes resulted in a "column not found" error. This is now fixed. Closes [#2313](https://github.com/Rdatatable/data.table/issues/2313). Thanks to @franknarf1 for the MRE.

#### NOTES

Expand Down
2 changes: 1 addition & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ chmatch2 <- function(x, table, nomatch=NA_integer_) {
if (length(xcols)) {
# TODO add: if (length(alloc)==nrow(x)) stop("There is no need to deep copy x in this case")
SDenv$.SDall = .Call(CsubsetDT,x,alloc,xcols) # must be deep copy when largest group is a subset
if (xdotcols) setattr(SDenv$.SDall, 'names', ansvars[seq_along(xcols)]) # now that we allow 'x.' prefix in 'j'
if (xdotcols) setattr(SDenv$.SDall, 'names', ansvars[xcolsAns]) # now that we allow 'x.' prefix in 'j', #2313 bug fix - [xcolsAns]
SDenv$.SD = if (!length(othervars)) SDenv$.SDall else shallow(SDenv$.SDall, setdiff(ansvars, othervars))
}
if (nrow(SDenv$.SDall)==0L) {
Expand Down
12 changes: 12 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -11337,6 +11337,18 @@ test(1867.14, fread(f), data.table(V1=1:9, x=DT$x, y=DT$y, v=DT$v), warning="Add
unlink(f)
# test(1867.15, fread(testDir("iterations.txt"))) # #1416 TODO (trailing tabs on most but not at the beginning and a "-" intended to mean missing but taken as text column name)

# non equi joins bug fix #2313
dt <- data.table(
patient.id = c(1L, 2L, 1L, 1L, 2L, 2L, 2L),
h.date = as.Date(c("2013/10/15", "2014/10/15", "2015/7/16", "2016/1/7",
"2015/12/20", "2015/12/25", "2016/2/10")))
setorder(dt)
dt[, `:=`(start.date = h.date - 365, end.date = h.date)]
# This line below would error without this fix
ans <- dt[dt, on = .(patient.id, h.date >= start.date, h.date <= end.date),
.(patient.id, i.start.date, i.end.date, g = .GRP, .N, x.h.date),
by=.EACHI]
test(1868, "x.h.date" %in% names(ans), TRUE)

##########################

Expand Down