Skip to content
Open
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

4. `rowwiseDT()` now provides a helpful error message when a complex object that is not a list (e.g., a function) is provided as a cell value, instructing the user to wrap it in `list()`, [#7219](https://github.com/Rdatatable/data.table/issues/7219). Thanks @kylebutts for the report and @venom1204 for the fix.

5. Non-equi joins combining an equality condition with two inequality conditions on the same column (e.g., `on = .(id == id, val >= lo, val <= hi)`) no longer error, [#7641](https://github.com/Rdatatable/data.table/issues/7641). The internal `chmatchdup` remapping of duplicate `rightcols` was overwriting the original column indices, causing downstream code to reference non-existent columns. Thanks @aitap for the diagnosis.

### Notes

1. {data.table} now depends on R 3.5.0 (2018).
Expand Down
9 changes: 6 additions & 3 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -1075,12 +1075,15 @@ replace_dot_alias = function(e) {
if (length(tt)) jisvars[tt] = paste0("i.",jisvars[tt])
if (length(duprightcols <- rightcols[duplicated(rightcols)])) {
nx = c(names_x, names_x[duprightcols])
rightcols = chmatchdup(names_x[rightcols], nx)
ansrightcols = chmatchdup(names_x[rightcols], nx) # indices into result namespace nx, #7641
nx = make.unique(nx)
} else nx = names_x
} else {
nx = names_x
ansrightcols = rightcols
}
ansvars = make.unique(c(nx, jisvars))
icols = c(leftcols, seq_along(i)[-leftcols])
icolsAns = c(rightcols, seq.int(length(nx)+1L, length.out=ncol(i)-length(unique(leftcols))))
icolsAns = c(ansrightcols, seq.int(length(nx)+1L, length.out=ncol(i)-length(unique(leftcols))))
xcols = xcolsAns = seq_along(x)[-rightcols]
}
ansvals = chmatch(ansvars, nx)
Expand Down
5 changes: 5 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -6954,6 +6954,11 @@ DT1 <- data.table(a=1L, key='a')
DT2 <- data.table(a=2.0, key='a')
test(1483.83, DT1[DT2, roll='nearest'], data.table(a=2L, key='a'))

# non-equi join with equi + 2 inequality conditions should not error, #7641
dt_x = data.table(id = c("A","A","B","B"), val = c(1,5,2,4), key = c("id","val"))
dt_i = data.table(id = c("A","B"), lo = c(2,1), hi = c(6,3))
test(1483.91, nrow(dt_x[dt_i, on = .(id == id, val >= lo, val <= hi)]), 2L)

# NULL items should be removed when making data.table from list, #842
# Original fix for #842 added a branch in as.data.table.list() using point()
# Then PR#3471 moved logic from data.table() into as.data.table.list() and now removes NULL items up front, so longer need for the branch
Expand Down
Loading