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 results in misleading variable names #2307

Closed
aleks-via opened this issue Aug 17, 2017 · 2 comments
Closed

Non-equi join results in misleading variable names #2307

aleks-via opened this issue Aug 17, 2017 · 2 comments
Milestone

Comments

@aleks-via
Copy link

Hi,

I've run into the following unexpected issue...

I am trying to join sales to shifts here by timestamp.

sales = data.table( sale_id = 1:5, sale_ts = (1:5)*5 )
shifts = data.table( shift_id= 21:23, shift_start = c(1,10,15), shift_end=c(9,14,19) )

sales[shifts, on=.(sale_ts>=shift_start, sale_ts<shift_end) ]

returns

   sale_id sale_ts sale_ts.1 shift_id
1:       1       1         9       21
2:       2      10        14       22
3:       3      15        19       23

This is misleading because the timestamps that are returned are not sale timestamps at all, but shift timestamps. I realize that reversing the code to do shifts[sales ... will give more appropriate results, but I'm likely not the only one confused by the behavior of the former formulation and possibly not the only one for whom this behavior resulted in some headache.

Thanks!

@Henrik-P
Copy link

Seems related to join column naming with on syntax

@aleks-via
Copy link
Author

aleks-via commented Aug 17, 2017

Yes, essentially the same issue as #1807 and a couple others. I hadn't done a good enough job searching. Closing as duplicate.

I do think since base merge doesn't support non-equi joins, it made sense there, but I think the SQL naming conventions make more sense for data.table.

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