Skip to content

Commit 5aaee92

Browse files
committed
fix test on windows
1 parent 6c68fb7 commit 5aaee92

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

R/bmerge.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
104104
} else stopf("Incompatible join types: %s is type integer64 but %s is type double and contains fractions", nm[2L], nm[1L])
105105
} else {
106106
# just integer and double left
107-
ic_idx = which(ic == icols)
107+
ic_idx = which(ic == icols) # check if on is joined on multiple conditions
108108
if (i_merge_type=="double") {
109109
coerce_x = FALSE
110110
if (!isReallyReal(i[[ic]])) {
@@ -113,7 +113,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
113113
# we've always coerced to int and returned int, for convenience.
114114
if (length(ic_idx)>1L) {
115115
xc_idx = xcols[ic_idx]
116-
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
116+
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
117117
if (isReallyReal(x[[xb]])) {
118118
coerce_x = FALSE
119119
break
@@ -127,7 +127,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
127127
set(callersi, j=ic, value=val) # change the shallow copy of i up in [.data.table to reflect in the result, too.
128128
if (length(ic_idx)>1L) {
129129
xc_idx = xcols[ic_idx]
130-
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
130+
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
131131
if (verbose) catf("Coercing double column %s (which contains no fractions) to type integer to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
132132
set(x, j=xb, value=cast_with_atts(x[[xb]], as.integer))
133133
}
@@ -144,7 +144,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
144144
set(i, j=ic, value=val)
145145
if (length(ic_idx)>1L) {
146146
xc_idx = xcols[ic_idx]
147-
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")]) {
147+
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")]) {
148148
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
149149
set(x, j=xb, value=cast_with_atts(x[[xb]], as.double))
150150
}

inst/tests/tests.Rraw

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12226,11 +12226,10 @@ DT1 = data.table(RANDOM_STRING = rand_strings(n),
1222612226
DATE = sample(seq(as.Date('2016-01-01'), as.Date('2016-12-31'), by="day"), n, replace=TRUE))
1222712227
DT2 = data.table(RANDOM_STRING = rand_strings(n),
1222812228
START_DATE = sample(seq(as.Date('2015-01-01'), as.Date('2017-12-31'), by="day"), n, replace=TRUE))
12229-
as.intDate = function(x) .Date(as.integer(as.Date(x)))
1223012229
DT2[, EXPIRY_DATE := START_DATE + floor(runif(1000, 200,300))]
12231-
DT1[, DT1_ID := .I][, DATE := as.intDate(DATE)]
12230+
DT1[, DT1_ID := .I][, DATE := as.Date(DATE)]
1223212231
cols = c("START_DATE", "EXPIRY_DATE")
12233-
DT2[, DT2_ID := .I][, (cols) := lapply(.SD, as.intDate), .SDcols=cols]
12232+
DT2[, DT2_ID := .I][, (cols) := lapply(.SD, as.Date), .SDcols=cols]
1223412233
ans1 = DT2[DT1, on=.(RANDOM_STRING, START_DATE <= DATE, EXPIRY_DATE >= DATE), .N, by=.EACHI ]$N > 0L
1223512234
tmp = DT1[DT2, on=.(RANDOM_STRING, DATE >= START_DATE, DATE <= EXPIRY_DATE), which=TRUE, nomatch=0L]
1223612235
ans2 = DT1[, DT1_ID %in% tmp]

0 commit comments

Comments
 (0)