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

FR: allow natural syntax for semi-anti-joins #1799

Closed
MichaelChirico opened this issue Aug 4, 2016 · 2 comments
Closed

FR: allow natural syntax for semi-anti-joins #1799

MichaelChirico opened this issue Aug 4, 2016 · 2 comments

Comments

@MichaelChirico
Copy link
Member

I posed this as an SO Q a while back; I still think it'd be a useful feature to see implemented for clarity of code.

Example:

DT <- data.table(a = rep(LETTERS, each = 10), id = rep(1:10, 26), key = c("a", "id"))
#desired syntax
DT[.(!"A", !3:4)]
#equivalent current syntax
DT[CJ(setdiff(unique(a), "A"), setdiff(unique(id), 3:4))]
@jangorecki
Copy link
Member

I think we first need to have != operator (and !(a%in%b)) for non-equi join, then it could be processed fast. Currently it may be better to use just i = a!="A" & !(id %in% 3:4) instead of proposed CJ syntax which won't scale in memory. Of course it depends on the data, but better to wait using vector scan than get a memory issues and swapping.

@arunsrinivasan
Copy link
Member

Agree with Jan. This'll become more straightforward when != is added to non-equi joins. Have added to #1801.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants