Skip to content

Commit 1e1225b

Browse files
Merge branch 'Rdatatable:master' into master
2 parents b2e6171 + 1ca9cf6 commit 1e1225b

File tree

11 files changed

+130
-50
lines changed

11 files changed

+130
-50
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
^\.devcontainer$
1818
^\.graphics$
1919
^\.github$
20+
^\.jj$
2021
^\.vscode$
2122
^\.zed$
2223
^\.lintr$

.github/workflows/test-coverage.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ jobs:
5151
covr::to_cobertura(cov)
5252
shell: Rscript {0}
5353

54-
- uses: codecov/codecov-action@v4
54+
- uses: codecov/codecov-action@v5
5555
with:
56-
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
57-
file: ./cobertura.xml
58-
plugin: noop
56+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
57+
files: ./cobertura.xml
58+
plugins: noop
5959
disable_search: true
6060
token: ${{ secrets.CODECOV_TOKEN }}
6161

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Version: 1.18.99
33
Title: Extension of `data.frame`
44
Depends: R (>= 3.5.0)
55
Imports: methods
6-
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils, xts, zoo (>= 1.8-1), yaml, litedown
6+
Suggests: bit64 (>= 4.0.0), R.utils, xts, zoo (>= 1.8-1), yaml, litedown
77
Enhances: knitr, xfun
88
Description: Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns, friendly and fast character-separated-value read/write. Offers a natural and flexible syntax, for faster development.
99
License: MPL-2.0 | file LICENSE

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
2. `set()` now automatically pre-allocates new column slots if needed, similar to what `:=` already does, [#1831](https://github.com/Rdatatable/data.table/issues/1831) [#4100](https://github.com/Rdatatable/data.table/issues/4100). Thanks to @zachokeeffe and @tyner for the report and @ben-schwen for the fix.
3232

33+
3. `fread("file://...")` works for file URIs with spaces, [#7550](https://github.com/Rdatatable/data.table/issues/7550). Thanks @aitap for the report and @MichaelChirico for the PR.
34+
3335
## data.table [v1.18.0](https://github.com/Rdatatable/data.table/milestone/37?closed=1) 23 December 2025
3436

3537
### BREAKING CHANGE

R/fread.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC")
6363
# input is data itself containing at least one \n or \r
6464
} else if (startsWith(input, " ")) {
6565
stopf("input= contains no \\n or \\r, but starts with a space. Please remove the leading space, or use text=, file= or cmd=")
66-
} else if (length(grep(' ', input, fixed=TRUE)) && !file.exists(input)) { # file name or path containing spaces is not a command
66+
} else if (length(grep(' ', input, fixed=TRUE)) && !file.exists(gsub("^file://", "", input))) { # file name or path containing spaces is not a command. file.exists() doesn't understand file:// (#7550)
6767
cmd = input
6868
if (input_has_vars && getOption("datatable.fread.input.cmd.message", TRUE)) {
6969
messagef("Taking input= as a system command because it contains a space ('%s'). If it's a filename please remove the space, or use file= explicitly. A variable is being passed to input= and when this is taken as a system command there is a security concern if you are creating an app, the app could have a malicious user, and the app is not running in a secure environment; e.g. the app is running as root. Please read item 5 in the NEWS file for v1.11.6 for more information and for the option to suppress this message.", cmd)

inst/tests/froll.Rraw

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) {
1111

1212
exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L)
1313
if (!exact_NaN) {
14-
cat("\n**** Skipping 7 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
14+
cat("\n**** Skipping 8 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
1515
# for Matt when he runs valgrind it is 53, but 64 when running regular R
1616
# froll.c uses long double and appears to require full long double accuracy in the algo='exact'
1717
}
@@ -1448,9 +1448,12 @@ test(6001.727, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact"), c(NA_
14481448
test(6001.728, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact", na.rm=TRUE), c(NA_real_,NA_real_,NA_real_))
14491449
test(6001.729, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact", na.rm=TRUE, partial=TRUE), c(NA_real_,NA_real_,NA_real_))
14501450
test(6001.730, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), fill=99, algo="exact", na.rm=TRUE), c(99,NA,NA))
1451-
y = c(1e8+2.980232e-8, 1e8, 1e8, 1e8) # CLAMP0 test
1452-
test(6001.731, frollvar(y, 3)[4L], 0)
1453-
test(6001.732, frollsd(y, 3)[4L], 0)
1451+
# numerical stability: we need to guarantee frollvar(x, n) >= 0 for all x, n
1452+
# the exact epsilon here is a bit implementation-dependent (as in #7546), but what's
1453+
# crucial is the output is never negative (or NaN after sqrt() for frollsd).
1454+
y = c(1e8+2.980232e-8, 1e8, 1e8, 1e8)
1455+
test(6001.731, between(frollvar(y, 3)[4L], 0, 1e-7))
1456+
test(6001.732, between(frollsd(y, 3)[4L], 0, 1e-7))
14541457
test(6001.733, frollvar(y, c(3,3,3,3), adaptive=TRUE)[4L], 0)
14551458
test(6001.734, frollsd(y, c(3,3,3,3), adaptive=TRUE)[4L], 0)
14561459
test(6001.740, frollvar(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.25,NA), c(NA,NA,0.25,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # ensure no nested parallelism in rolling functions #7352

inst/tests/knitr.Rmd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```{r test_id, message=FALSE, results="show", echo=TRUE, warning=FALSE}
2+
require(data.table) # print?
3+
DT = data.table(x=1:3, y=4:6) # no
4+
DT # yes
5+
DT[, z := 7:9] # no
6+
print(DT[, z := 10:12]) # yes
7+
if (1 < 2) DT[, a := 1L] # no
8+
DT # yes
9+
```
10+
Some text.

inst/tests/knitr.md.save

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
``` r
3+
require(data.table) # print?
4+
DT = data.table(x=1:3, y=4:6) # no
5+
DT # yes
6+
```
7+
8+
```
9+
## x y
10+
## <int> <int>
11+
## 1: 1 4
12+
## 2: 2 5
13+
## 3: 3 6
14+
```
15+
16+
``` r
17+
DT[, z := 7:9] # no
18+
print(DT[, z := 10:12]) # yes
19+
```
20+
21+
```
22+
## x y z
23+
## <int> <int> <int>
24+
## 1: 1 4 10
25+
## 2: 2 5 11
26+
## 3: 3 6 12
27+
```
28+
29+
``` r
30+
if (1 < 2) DT[, a := 1L] # no
31+
DT # yes
32+
```
33+
34+
```
35+
## x y z a
36+
## <int> <int> <int> <int>
37+
## 1: 1 4 10 1
38+
## 2: 2 5 11 1
39+
## 3: 3 6 12 1
40+
```
41+
Some text.

inst/tests/other.Rraw

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ pkgs = c("DBI", "RSQLite", "bit64", "caret", "dplyr", "gdata", "ggplot2", "hexbi
1111
# "yaml" # for fread's yaml argument (csvy capability)
1212
# # zoo # In DESCRIPTION:Suggests otherwise R CMD check warning: '::' or ':::' import not declared from: 'zoo'; it is tested in other.Rraw though
1313

14-
if (exists("test.data.table",.GlobalEnv,inherits=FALSE) ||
14+
if (exists("test.data.table", .GlobalEnv, inherits=FALSE) ||
1515
!"package:data.table" %in% search()) {
16-
stop("Usage: R CMD INSTALL; require(data.table); test.data.table('other.Rraw')")
16+
stop(
17+
"Usage: R CMD INSTALL; require(data.table); test.data.table('other.Rraw')\n",
18+
" Did you try running it under cc()?"
19+
)
1720
# running other.Raw in dev mode (i.e. when data.table is not installed) is not intended to work
1821
}
1922

@@ -47,7 +50,7 @@ cat("\n")
4750
print(sessionInfo())
4851
cat("\n")
4952

50-
if (all(c("package:reshape","package:reshape2") %in% search())) {
53+
if (all(c("package:reshape", "package:reshape2") %in% search())) {
5154
warning("Packages 'reshape' and 'reshape2' are both loaded. There have been problems before when you don't use the :: namespace prefix to disambiguate. Probably best to either remove.packages('reshape') and use reshape2 instead, or always use :: when packages mask non-generic names.")
5255
}
5356

@@ -181,10 +184,14 @@ if (loaded[["knitr"]]) {
181184
# kable in knitr v1.6 uses DF[...] syntax inside it but the user might have passed a data.table.
182185
# Which is fine and works thanks to cedta().
183186
DT = data.table(x=1, y=2)
184-
test(11, kable(DT), output="x.*y.*1.*2")
185-
invisible(knit(testDir("knitr.Rmd"), quiet=TRUE))
186-
cat(readLines("knitr.md"), sep="\n")
187-
invisible(file.remove("knitr.md"))
187+
test(11.1, kable(DT), output="x.*y.*1.*2")
188+
local({
189+
old = options(datatable.print.class=TRUE)
190+
tmp = tempfile()
191+
on.exit({unlink(tmp); options(old)})
192+
invisible(knit(testDir("knitr.Rmd"), tmp, quiet=TRUE))
193+
test(11.2, tools::Rdiff(tmp, testDir("knitr.md.save")), 0L)
194+
})
188195
}
189196

190197
if (loaded[["parallel"]]) {
@@ -531,6 +538,9 @@ if (loaded[["xts"]]) { # was 1465 in tests.Rraw, #5516
531538
# was 2108 in tests.Rraw, #5516
532539
# first and last should no longer load xts namespace, #3857, below commented test for interactive validation when xts present but not loaded or attached
533540
# stopifnot("xts"%in%installed.packages(), !isNamespaceLoaded("xts")); library(data.table); x=as.POSIXct("2019-01-01"); last(x); stopifnot(!isNamespaceLoaded("xts"))
541+
# in case the search path is wrong
542+
if (!identical(last, data.table::last)) last = data.table::last
543+
if (!identical(first, data.table::first)) first = data.table::first
534544
local({
535545
x = as.POSIXct("2019-09-09")+0:1
536546
old = options(datatable.verbose=TRUE); on.exit(options(old))
@@ -686,6 +696,8 @@ if (loaded[["nanotime"]]) {
686696
# was 2080.01-05 in tests.Rraw, #5516
687697
n = nanotime(1:4)
688698
n[2L] = NA
699+
# in case the search path is wrong
700+
if (!identical(between, data.table::between)) between = data.table::between
689701
local({
690702
old = options(datatable.verbose=TRUE); on.exit(options(old))
691703
test(24.1, between(n, nanotime(2), nanotime(10)), c(FALSE, NA, TRUE, TRUE), output="between parallel processing of integer64")
@@ -779,15 +791,15 @@ if (loaded[["nanotime"]]) {
779791

780792
# tables() with large environment #6607
781793
.e <- new.env() ## to not populate the .GlobalEnv
782-
.e[["DT"]] <- as.data.table(lapply(1:15,function(i) runif(20e6)))
783-
res <- tables(env=.e)
794+
.e[["DT"]] <- setDT(replicate(15L, runif(2e7), simplify=FALSE))
795+
invisible(capture.output(res <- tables(env=.e)))
784796
test(32, res[, .(NAME,NROW,NCOL,MB)], data.table(NAME="DT",NROW=20000000L,NCOL=15L,MB=2288.0))
785797
rm(.e, res)
786798

787799
if (loaded[["vctrs"]]) {
788800
# vctrs::list_of() columns are treated the same as other list() columns
789801
DT = data.table(a = 1, b = list_of(mtcars))
790-
test(33, DT, output="<vctrs_list_of>.*<data\\.frame\\[32x11\\]>")
802+
test(33, options=c(datatable.print.class=TRUE), DT, output="<vctrs_list_of>.*<data\\.frame\\[32x11\\]>")
791803
}
792804

793805
# NB: currently, RSQLite requires DBI, so partially redundant, but future-proof.

inst/tests/tests.Rraw

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22008,3 +22008,13 @@ test(2356.2, options=c(datatable.alloccol=1L), set(DT, j="c", value=3), data.tab
2200822008
# ensure := and set are consistent if they need to overallocate
2200922009
DT = data.table(); DT2 = data.table()
2201022010
test(2356.3, options=c(datatable.alloccol=1L), {for (i in seq(10L)) set(DT, j = sprintf("V%d",i), value = i); DT}, {for (i in seq(10)) DT2[, sprintf("V%d",i) := i]; DT2})
22011+
22012+
# fread works on file:// URIs with spaces, #7550
22013+
local({
22014+
f = tempfile("with spaces"); on.exit(unlink(f))
22015+
DT = data.table(a = 1L, b = 2L)
22016+
fwrite(DT, f)
22017+
22018+
test(2357.1, fread(f), DT)
22019+
test(2357.2, fread(paste0("file://", f)), DT)
22020+
})

0 commit comments

Comments
 (0)