Skip to content

Commit 4b53e30

Browse files
committed
test for #7364: cartesian join bug with transformed data
1 parent 738779b commit 4b53e30

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

inst/tests/tests.Rraw

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21837,3 +21837,28 @@ DT[, V1000 := 20:1]
2183721837
test(2343.1, forderv(DT, by=names(DT), sort=FALSE, retGrp=TRUE), forderv(DT, by=c("V1", "V1000"), sort=FALSE, retGrp=TRUE))
2183821838
x = c(rep(0, 7e5), 1e6)
2183921839
test(2343.2, forderv(list(x)), integer(0))
21840+
21841+
# Test for issue #7364 - cartesian join returns fewer rows than expected
21842+
test(9061.1, {
21843+
daily_dat = data.table(
21844+
id = c(1L, 0L, 1L, 0L),
21845+
label = c("ONE", "ZERO", "ONE", "ZERO"),
21846+
week_day = c("FRI", "FRI", "SAT", "SAT"),
21847+
key = "week_day"
21848+
)
21849+
21850+
transformed_daily_dat = daily_dat[, .(
21851+
id,
21852+
label = fifelse(id == 0L, "ZERO", "ONE"),
21853+
week_day
21854+
)]
21855+
21856+
result = transformed_daily_dat[
21857+
data.table(label = "ONE", id = 1L),
21858+
on = "label",
21859+
allow.cartesian = TRUE
21860+
]
21861+
21862+
nrow(result)
21863+
}, 2L) # Expected: 2 rows, currently returns 1
21864+

0 commit comments

Comments
 (0)