You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix incorrect keying after merge of keyed, non-alphabetic factor and character columns (#5362)
* add fix
* add test
* add more tests
* add NEWS
* typo
* sentence structure
* state bug more precisely
* unwield lengthy if with ws
* more tests
* extend NEWS for mirror casse
* update NEWS
* vapply on single columns instead of whole subset
* use .shallow
* suggested NEWS wording
* add OPs original example more exactly to the regression test
* add some tests of multiple join columns
* avoid using column x in table x
* attempt to refactor into huge helper (🤞)
* trailing ws
* fix (?) tests
* need to pass 'ans' too
* don't reuse overloaded name 'let'
* typo
* remove apparently vestigial check
---------
Co-authored-by: Michael Chirico <[email protected]>
Co-authored-by: Michael Chirico <[email protected]>
Copy file name to clipboardExpand all lines: NEWS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,8 @@
78
78
79
79
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.
80
80
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.
82
+
81
83
### NOTES
82
84
83
85
1. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PRs and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.
if ( (keylen>len||chk) &&!.Call(CisOrderedSubset, irows, nrow(x))) {
1358
-
keylen=if (!chk) lenelse0L# fix for #1268
1359
-
}
1360
-
## check key on i as well!
1361
-
ichk= is.data.table(i) && haskey(i) &&
1362
-
identical(head(key(i), length(leftcols)), names_i[leftcols]) # i has the correct key, #3061
1363
-
if (keylen&& (ichk|| is.logical(i) || (.Call(CisOrderedSubset, irows, nrow(x)) && ((roll==FALSE) || length(irows) ==1L)))) # see #1010. don't set key when i has no key, but irows is ordered and roll != FALSE
1364
-
setattr(ans,"sorted",head(key(x),keylen))
1365
-
}
1351
+
# NB: could be NULL
1352
+
setattr(ans, "sorted", .join_result_key(x, i, ans, if (!missing(on)) names(on), ansvars, leftcols, rightcols, names_i, irows, roll))
1366
1353
setattr(ans, "class", class(x)) # retain class that inherits from data.table, #64
0 commit comments