Skip to content

Commit d273fbd

Browse files
use getVar over findVar (#7575)
1 parent 4d30c7f commit d273fbd

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

NEWS.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818

1919
2. `[,showProgress=]` and `options(datatable.showProgress)` now accept an integer to control the progress bar update interval in seconds, allowing finer control over progress reporting frequency; `TRUE` uses the default 3-second interval, [#6514](https://github.com/Rdatatable/data.table/issues/6514). Thanks @ethanbsmith for the report and @ben-schwen for the PR.
2020

21-
### Notes
22-
23-
1. {data.table} now depends on R 3.5.0 (2018).
24-
25-
2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR.
26-
27-
3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation.
28-
29-
4. Removed use of non-API macros `ATTRIB`, `SET_ATTRIB`, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here.
30-
3121
### BUG FIXES
3222

3323
1. `fread()` with `skip=0` and `(header=TRUE|FALSE)` no longer skips the first row when it has fewer fields than subsequent rows, [#7463](https://github.com/Rdatatable/data.table/issues/7463). Thanks @emayerhofer for the report and @ben-schwen for the fix.
@@ -38,6 +28,16 @@
3828

3929
4. `sum(<int64 column>)` by group is correct with missing entries and GForce activated ([#7571](https://github.com/Rdatatable/data.table/issues/7571)). Thanks to @rweberc for the report and @manmita for the fix. The issue was caused by a faulty early `break` that spilled between groups, and resulted in silently incorrect results!
4030

31+
### Notes
32+
33+
1. {data.table} now depends on R 3.5.0 (2018).
34+
35+
2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR.
36+
37+
3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation.
38+
39+
4. Removed use of non-API `ATTRIB`, `SET_ATTRIB`, and `findVar` [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here, and @MichaelChirico for the easy fix to replace `findVar` with `R_getVar`.
40+
4141
## data.table [v1.18.0](https://github.com/Rdatatable/data.table/milestone/37?closed=1) 23 December 2025
4242

4343
### BREAKING CHANGE

src/data.table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# define LOGICAL_RO LOGICAL
1515
#endif
1616
#if R_VERSION < R_Version(4, 5, 0)
17+
# define R_getVar(x, env, inherits) findVar(x, env)
1718
# define isDataFrame(x) isFrame(x) // #6180
1819
# define CLEAR_ATTRIB(x) SET_ATTRIB(x, R_NilValue)
1920
# define ANY_ATTRIB(x) (!(isNull(ATTRIB(x))))

src/dogroups.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
9494
ngrpcols = length(grpcols);
9595
nrowgroups = length(VECTOR_ELT(groups,0));
9696
// fix for longstanding FR/bug, #495. E.g., DT[, c(sum(v1), lapply(.SD, mean)), by=grp, .SDcols=v2:v3] resulted in error.. the idea is, 1) we create .SDall, which is normally == .SD. But if extra vars are detected in jexp other than .SD, then .SD becomes a shallow copy of .SDall with only .SDcols in .SD. Since internally, we don't make a copy, changing .SDall will reflect in .SD. Hopefully this'll workout :-).
97-
SEXP SDall = PROTECT(findVar(install(".SDall"), env)); nprotect++; // PROTECT for rchk
98-
SEXP SD = PROTECT(findVar(install(".SD"), env)); nprotect++;
97+
SEXP SDall = PROTECT(R_getVar(install(".SDall"), env, false)); nprotect++; // PROTECT for rchk
98+
SEXP SD = PROTECT(R_getVar(install(".SD"), env, false)); nprotect++;
9999

100100
int updateTime = INTEGER(showProgressArg)[0];
101101
const bool showProgress = updateTime > 0 && ngrp > 1; // showProgress only if more than 1 group
@@ -125,12 +125,12 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
125125
error("!length(bynames)[%d]==length(groups)[%d]==length(grpcols)[%d]", length(bynames), length(groups), length(grpcols)); // # notranslate
126126
// TO DO: check this check above.
127127

128-
N = PROTECT(findVar(install(".N"), env)); nprotect++; // PROTECT for rchk
128+
N = PROTECT(R_getVar(install(".N"), env, false)); nprotect++; // PROTECT for rchk
129129
hash_set(specials, N, -1); // marker for anySpecialStatic(); see its comments
130-
GRP = PROTECT(findVar(install(".GRP"), env)); nprotect++;
130+
GRP = PROTECT(R_getVar(install(".GRP"), env, false)); nprotect++;
131131
hash_set(specials, GRP, -1); // marker for anySpecialStatic(); see its comments
132-
iSD = PROTECT(findVar(install(".iSD"), env)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS)
133-
xSD = PROTECT(findVar(install(".xSD"), env)); nprotect++;
132+
iSD = PROTECT(R_getVar(install(".iSD"), env, false)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS)
133+
xSD = PROTECT(R_getVar(install(".xSD"), env, false)); nprotect++;
134134
R_len_t maxGrpSize = 0;
135135
const int *ilens = INTEGER(lens), n=LENGTH(lens);
136136
for (R_len_t i=0; i<n; ++i) {

0 commit comments

Comments
 (0)