You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- The date related `ProductReceivedProd2` was omitted from this new table.
```{r}
ProductReceivedProd2[ProductSalesProd2,
on = list(product_id, date < date)]
```
which I did not understood initially the full consequences of this, but later, working with my own data, I realised it means losing data from x (if doing x[y, on = .(xid = yid, date < ydate),...]).
I may use something like x[y, on = .(xid = yid), j = .(date = x.date), ...], but then I have to specify inside j = .(...) all the columns from x and y (which may be a lot). I have tried including .SD, x.SD, x..SD, i.SD, i..SD in distinct ways, but nothing of this works.
Is there an abbreviated way to include all x and y (i) columns in the join, while using j to specify some names or some concrete data columns?
Thank you for the suggestion! Including examples like
p1[p2, names(p1), on = .(symbol, date >= start_date, date <= end_date), with = FALSE]
in the Join vignette would indeed be helpful for users dealing with non-equi joins and complex conditions like date ranges. It addresses a common scenario and clarifies how to retain columns from the left table (p1) efficiently.
However, to make the vignette even more user-friendly, we could:
Highlight the importance of using prefixes (x. or i.) to avoid ambiguity in join columns.
Provide additional examples that show how to handle situations where both tables have overlapping column names.
Include a brief explanation of why data.table behaves this way during joins (right outer join logic and column precedence).
I believe this would make the documentation more comprehensive and address common pitfalls users face with non-equi joins. I'd be happy to collaborate or review if this is added to the vignette!
Since, as you mentioned, the root cause seems to be addressed by PR #3093, but that PR is still open, I think it would be useful to improve the documentation in the meantime. Many users find the current non-equi join behavior surprising—especially that x[i, on=..., j=...] drops x columns unless explicitly referenced.
My plan:
Add a note to the non-equi join section of datatable-joins.Rmd explaining the current behavior.
Include an example showing the unexpected result and an idiomatic workaround using x., .SD, or a programmatic approach.
This should help reduce confusion and improve usability until #3093 is merged. Let me know if this direction sounds good!
Activity
tdhock commentedon Feb 10, 2025
related to #4949
tdhock commentedon Feb 10, 2025
probably fixed by #3093 (please look at that PR, it needs help)
iagogv3 commentedon Feb 13, 2025
@tdhock Thanks for pointing me to the original issue and to the PR (I looked at it, but it is too much complex for the time I have now)
tdhock commentedon Feb 13, 2025
me too
iagogv3 commentedon Mar 4, 2025
BTW, meanwhile, examples such as
in #4949 (comment) could be added to the Join vignette, commenting this issue. WDYT @venom1204?
venom1204 commentedon Mar 4, 2025
Thank you for the suggestion! Including examples like
in the Join vignette would indeed be helpful for users dealing with non-equi joins and complex conditions like date ranges. It addresses a common scenario and clarifies how to retain columns from the left table (p1) efficiently.
However, to make the vignette even more user-friendly, we could:
I believe this would make the documentation more comprehensive and address common pitfalls users face with non-equi joins. I'd be happy to collaborate or review if this is added to the vignette!
venom1204 commentedon Jul 7, 2025
Hi @tdhock,
Would a documentation update be helpful here?
Since, as you mentioned, the root cause seems to be addressed by PR #3093, but that PR is still open, I think it would be useful to improve the documentation in the meantime. Many users find the current non-equi join behavior surprising—especially that x[i, on=..., j=...] drops x columns unless explicitly referenced.
My plan:
Add a note to the non-equi join section of datatable-joins.Rmd explaining the current behavior.
Include an example showing the unexpected result and an idiomatic workaround using x., .SD, or a programmatic approach.
This should help reduce confusion and improve usability until #3093 is merged. Let me know if this direction sounds good!
tdhock commentedon Jul 8, 2025
I think it would be better if you could put some work into fixing #3093