Skip to content

Commit 1fc2e81

Browse files
Account for roll='nearest'
1 parent 548410d commit 1fc2e81

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
7979
17. A data.table with a column of class `vctrs_list_of` (from package {vctrs}) prints as expected, [#5948](https://github.com/Rdatatable/data.table/issues/5948). Before, they could be printed messily, e.g. printing every entry in a nested data.frame. Thanks @jesse-smith for the report, @DavisVaughan and @r2evans for contributing, and @MichaelChirico for the PR.
8080
81-
18. Fixed incorrect sorting of merges where the first column of a key is a factor with non-`sort()`-ed levels (e.g. `factor(1:2, 2:1)` and it is joined to a character column, [#5361](https://github.com/Rdatatable/data.table/issues/5361). Thanks to @gbrunick for the report and Benjamin Schwendinger for the fix.
81+
18. Fixed incorrect sorting of merges where the first column of a key is a factor with non-`sort()`-ed levels (e.g. `factor(1:2, 2:1)` and it is joined to a character column, [#5361](https://github.com/Rdatatable/data.table/issues/5361). Thanks to @gbrunick for the report, Benjamin Schwendinger for the fix, and @MichaelChirico for a follow-up fix caught by revdep testing.
8282
8383
19. Spurious warnings from internal code in `cube()`, `rollup()`, and `groupingsets()` are no longer surfaced to the caller, [#6964](https://github.com/Rdatatable/data.table/issues/6964). Thanks @ferenci-tamas for the report and @venom1204 for the fix.
8484

R/data.table.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,9 @@ replace_dot_alias = function(e) {
20482048
if (!.Call(CisOrderedSubset, irows, nrow(x)))
20492049
return(NULL)
20502050

2051-
# see #1010. don't set key when i has no key, but irows is ordered and !roll
2052-
if (roll && length(irows) != 1L)
2051+
# see #1010. don't set key when i has no key, but irows is ordered and isFALSE(roll)
2052+
# NB: roll could still be a string like 'nearest', #7146
2053+
if (!isFALSE(roll) && length(irows) != 1L)
20532054
return(NULL)
20542055

20552056
new_key <- head(x_key, key_length)

inst/tests/tests.Rraw

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7123,6 +7123,11 @@ dt3 <- merge(dt1, dt2, by="x")
71237123
test(1483.81, key(dt3), "x")
71247124
test(1483.82, nrow(dt3[x %in% "c", ]), 2L)
71257125

7126+
# avoid regression of roll='nearest' join of int->double, #7146
7127+
DT1 <- data.table(a=1L, key='a')
7128+
DT2 <- data.table(a=2.0, key='a')
7129+
test(1483.83, DT1[DT2, roll='nearest'], data.table(a=2L, key='a'))
7130+
71267131
# NULL items should be removed when making data.table from list, #842
71277132
# Original fix for #842 added a branch in as.data.table.list() using point()
71287133
# 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

0 commit comments

Comments
 (0)