Skip to content

Commit

Permalink
fix test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-schwen committed Nov 27, 2024
1 parent 6c68fb7 commit 5aaee92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions R/bmerge.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
} else stopf("Incompatible join types: %s is type integer64 but %s is type double and contains fractions", nm[2L], nm[1L])
} else {
# just integer and double left
ic_idx = which(ic == icols)
ic_idx = which(ic == icols) # check if on is joined on multiple conditions
if (i_merge_type=="double") {
coerce_x = FALSE
if (!isReallyReal(i[[ic]])) {
Expand All @@ -113,7 +113,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
# we've always coerced to int and returned int, for convenience.
if (length(ic_idx)>1L) {
xc_idx = xcols[ic_idx]
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
if (isReallyReal(x[[xb]])) {
coerce_x = FALSE
break
Expand All @@ -127,7 +127,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
set(callersi, j=ic, value=val) # change the shallow copy of i up in [.data.table to reflect in the result, too.
if (length(ic_idx)>1L) {
xc_idx = xcols[ic_idx]
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "double")]) {
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)
set(x, j=xb, value=cast_with_atts(x[[xb]], as.integer))
}
Expand All @@ -144,7 +144,7 @@ bmerge = function(i, x, icols, xcols, roll, rollends, nomatch, mult, ops, verbos
set(i, j=ic, value=val)
if (length(ic_idx)>1L) {
xc_idx = xcols[ic_idx]
for (xb in xcols[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")]) {
for (xb in xc_idx[which(vapply_1c(x[0L, xc_idx, with=FALSE], getClass) == "integer")]) {
if (verbose) catf("Coercing integer column %s to type double for join to match type of %s.\n", paste0("x.", names(x)[xb]), xname)
set(x, j=xb, value=cast_with_atts(x[[xb]], as.double))
}
Expand Down
5 changes: 2 additions & 3 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -12226,11 +12226,10 @@ DT1 = data.table(RANDOM_STRING = rand_strings(n),
DATE = sample(seq(as.Date('2016-01-01'), as.Date('2016-12-31'), by="day"), n, replace=TRUE))
DT2 = data.table(RANDOM_STRING = rand_strings(n),
START_DATE = sample(seq(as.Date('2015-01-01'), as.Date('2017-12-31'), by="day"), n, replace=TRUE))
as.intDate = function(x) .Date(as.integer(as.Date(x)))
DT2[, EXPIRY_DATE := START_DATE + floor(runif(1000, 200,300))]
DT1[, DT1_ID := .I][, DATE := as.intDate(DATE)]
DT1[, DT1_ID := .I][, DATE := as.Date(DATE)]
cols = c("START_DATE", "EXPIRY_DATE")
DT2[, DT2_ID := .I][, (cols) := lapply(.SD, as.intDate), .SDcols=cols]
DT2[, DT2_ID := .I][, (cols) := lapply(.SD, as.Date), .SDcols=cols]
ans1 = DT2[DT1, on=.(RANDOM_STRING, START_DATE <= DATE, EXPIRY_DATE >= DATE), .N, by=.EACHI ]$N > 0L
tmp = DT1[DT2, on=.(RANDOM_STRING, DATE >= START_DATE, DATE <= EXPIRY_DATE), which=TRUE, nomatch=0L]
ans2 = DT1[, DT1_ID %in% tmp]
Expand Down

0 comments on commit 5aaee92

Please sign in to comment.