Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-equi join breaks inconsistently when using .SD #3635

Closed
UweBlock opened this issue Jun 8, 2019 · 0 comments · Fixed by #3656
Closed

non-equi join breaks inconsistently when using .SD #3635

UweBlock opened this issue Jun 8, 2019 · 0 comments · Fixed by #3656
Assignees
Labels
bug non-equi joins rolling, overlapping, non-equi joins
Milestone

Comments

@UweBlock
Copy link
Contributor

UweBlock commented Jun 8, 2019

I have asked on SO for an explanation of this inconsistent behaviour. @franknarf1 has replied that this might be a bug which could be related to #1989.

Depending on the "direction" or "type" of join, using j = .SD throws an error:

library(data.table)
(d1 <- fread("a,b\n1,11\n6,16"))
#    a  b
# 1: 1 11
# 2: 6 16
(d2 <- data.table(r = 1:5, s = seq(0, 20, 5)))
#    r  s
# 1: 1  0
# 2: 2  5
# 3: 3 10
# 4: 4 15
# 5: 5 20

# case A

d1[d2, on = .(a <= s, b >= s)]
#     a  b r
# 1:  0  0 1
# 2:  5  5 2
# 3: 10 10 3
# 4: 10 10 3
# 5: 15 15 4
# 6: 20 20 5

d1[d2, on = .(a <= s, b >= s), j = .SD]
# Error in [.data.table(d1, d2, on = .(a <= s, b >= s), j = .SD) :
# column(s) not found: a

# case B

d2[d1, on = .(s >= a, s <= b)]
#    r s s.1
# 1: 2 1  11
# 2: 3 1  11
# 3: 3 6  16
# 4: 4 6  16

d2[d1, on = .(s >= a, s <= b), j = .SD]
#    r s
# 1: 2 1
# 2: 3 1
# 3: 3 6
# 4: 4 6

I have reproduced this behaviour with R version 3.6.0 and data.table versions 1.11.8, 1.12.2, and 1.12.3 on

Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

and with R version 3.6.0 and data.table version 1.12.3 on

Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
@UweBlock UweBlock changed the title non-equi join breaks when using .SD inconsistently non-equi join breaks inconsistently when using .SD Jun 8, 2019
@arunsrinivasan arunsrinivasan self-assigned this Jun 22, 2019
@arunsrinivasan arunsrinivasan added bug non-equi joins rolling, overlapping, non-equi joins labels Jun 22, 2019
@arunsrinivasan arunsrinivasan added this to the 1.12.4 milestone Jun 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug non-equi joins rolling, overlapping, non-equi joins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants