From 173335715558db32d95a39d10462d5f5d3e2de4a Mon Sep 17 00:00:00 2001 From: shrektan Date: Sat, 7 Nov 2020 21:22:45 +0800 Subject: [PATCH] rbind() now works with DTs with zero-length ordered factors --- NEWS.md | 2 ++ inst/tests/tests.Rraw | 3 +++ src/rbindlist.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index afde983b46..953d368c8a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,8 @@ 1. `as.matrix()` now retains the column type for the empty matrix result, [#4762](https://github.com/Rdatatable/data.table/issues/4762). Thus, for example, `min(DT[0])` where DT's columns are numeric, is now consistent with non-empty all-NA input and returns `Inf` with R's warning `no non-missing arguments to min; returning Inf` rather than R's error `only defined on a data frame with all numeric[-alike] variables`. Thanks to @mb706 for reporting. +2. Fix a bug that DT can't `rbind()` two DT with length-0 ordered factors and after that data.table may throw errors complaining "savetl_init checks failed", [#4795](https://github.com/Rdatatable/data.table/issues/4795). Thanks to @shrektan for reporting and fixing. + ## NOTES 1. Continuous daily testing by CRAN using latest daily R-devel revealed, within one day of the change to R-devel, that a future version of R would break one of our tests, [#4769](https://github.com/Rdatatable/data.table/issues/4769). The characters "-alike" were added into one of R's error messages, so our too-strict test which expected the error `only defined on a data frame with all numeric variables` will fail when it sees the new error message `only defined on a data frame with all numeric-alike variables`. We have relaxed the pattern the test looks for to `data.*frame.*numeric` well in advance of the future version of R being released. Readers are reminded that CRAN is not just a host for packages. It is also a giant test suite for R-devel. For more information, [behind the scenes of cran, 2016](https://www.h2o.ai/blog/behind-the-scenes-of-cran/). diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 9d207f8866..dd54131323 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -17235,3 +17235,6 @@ test(2160.2, x[, v0 := fcase( )][c(1,3,74,96,100), round(v0,1)], c(0, -24.7, 82.5, 6.7, 0)) rm(x) +# allow bind two length-0 ordered factors #4795 +dt = data.table(A = ordered(character())) +test(2161, rbind(dt, dt), dt) diff --git a/src/rbindlist.c b/src/rbindlist.c index bb42502be6..5dab7fff51 100644 --- a/src/rbindlist.c +++ b/src/rbindlist.c @@ -273,7 +273,7 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg) for(int j=0; j